Loading...
 
Features / Usability

Features / Usability


Forcing word case

posts: 29

Hi guys.

I've been digging around (google and tiki) on this for a few days without any luck. And I'm starting to think it can't be done.

When creating a wiki page, is there a way to force { {page}} to be either uppercase or lowercase?
Example: ForceCase({ {page}}, case="upper")

If this can be done, I can use { {page}} as part of an URL to an external source as the page title.
Example: ! [http://example.com/wiki/lang/{ {page}}| ForceCase({ {page}}, case="lower")|new]

Thanks!

posts: 214

There might be other ways to do it, but you could use the Smarty plugin with "eval" and the Smarty Variable Modifiers "lower" or "upper".

The smarty function has to be enabled in "Plugins". And Smarty eval does not work in all versions of Tiki, so it depends on the version you are using if it will work or not.
When you code the plugin, you will get the message "incorrect parameter" if it does not work in your Tiki version (it does not work in Tiki 9.11svn, but it works in 12.4svn, 14.1svn, and 15.0svn).

This would display the page name in lower case:

Copy to clipboard
{smarty name="eval" var="{$page|lower}"}

 

 

Tom


posts: 29

Thanks for your reply, Tom.

I Looked over those links you provided. Unfortunately, I'm not much closer than I was before I started. I'm not a PHP programmer, and I've never used Smarty, but that hasn't stop me from digging around in the wikiplugin_*.php code trying to figure things out. 

Using those  wikiplugin_*.php files for reference, I did code up something that was partially recongnized in Tiki (no errors, but the popup plugin form(?) not fully functional). I haven't given up yet.

Is there some sort of a Tiki programmer's documentation listing the Tiki variables and a description of the info they provide/give access to? 

Nothing like jumping into a big hole blindfolded! But, I always did like a good challenge.

Thanks. 

 


posts: 214

I am not sure why you think the solution I gave would require any PHP programming.  Did you try my suggestion?

Tiki's wiki syntax does not have a "force upper case" or "force lower case" option.  Tiki wiki syntax is extended with plugins.  There are no "force upper case" or "force lower case" plugins, but some plugins have options that could be used to lower case a string.

Your example used the page name variable as the thing you wanted to force into lower case.  

The page name is also available in a smarty variable, $page. And there is a smarty plugin which gives you access to smarty variables and smarty functions.
So your example:

Copy to clipboard
[http://example.com/wiki/lang/{ {page}}| ForceCase(, case="lower")|new]

Could be accomplished by using the smarty plugin:

Copy to clipboard
[http://example.com/wiki/lang/|{smarty name="eval" var="{$page|lower}"}|new]

The "|lower" after the $page in the "var=" applies the smarty lower function to the $page smarty variable.  It doesn't need any other programming.

If that wasn't what you wanted, maybe you could explain it with more examples?

You can find out all of the smarty variables available to you by turning on the "Debugger Console" and having it list out all the smarty variables.

Go to Features, select the "Programmer" tab, and enable "Debugger Console".
Once that is done, there will be a new option in the menu: "(debug)".
Click on that option and then scroll to the top of the page and there should be a "Debugger Console" with a "Command:" text box.
If you enter "slist" for the command and click on "exec", it will list all of the smarty variables.
But I recommend you enter "help" for the command and click on "exec" for more information before doing the "slist" command.


There are other plugins which could be used to set text into lower case.

The Tag plugin with the style parameter "text-transform: lowercase;" could be used to change the case to lower.  In your example it would be:

Copy to clipboard
[http://example.com/wiki/lang/|{TAG(style="text-transform: lowercase;")}{TAG}|new]


I don't recommend using this next option because it will not work after PHP version 5.5.

Plugin Regex could also be used (but only for PHP versions 5.5 or lower as that plugin uses PHP preg_replace and to change the case of the letters would require the "\e" modifier which was depreciated in PHP 5 and is ignored in PHP 7).

Create a webpage named "ForceLowerCase".
Put the string below as the only thing on that page:

Copy to clipboard
/A-Z/e::strtolower("$0")

and then save the page.

In your example, to use the Regex plugin with the ForceLowerCase page to change the case of the page name would be:

Copy to clipboard
[http://example.com/wiki/lang/|{REGEX(pageName="ForceLowerCase")}{REGEX}|new]

(This did work with PHP Version 5.5.13 and Tiki 15.0 svn though.)

Tom

 

 

posts: 29
I am not sure why you think the solution I gave would require any PHP programming.  Did you try my suggestion?


I'm fairly new to Tiki. The Smarty link you gave showed a PHP example, along with you saying "when you code the plugin", and then everything I was reading about coding plugins pointed to coding a plugin in PHP. And no, I didn't try your suggestion because, quite frankly, I was confused about what to do with it. My bad for being a  Tiki noob.

Your examples this time make much more sense as to how the are used. I will give the first two a try to see which one works best for me.

Although I have full control over which PHP version is on my server, I have no interest in using the last example that could potentially blow up later. And with over 400 wiki pages that would be using this, I would have to write an app to clean up that mess.

Thanks.

 

 


posts: 214

If you need to use this hundreds of times, then perhaps you could make your own "force lower case" plugin to reduce the amount of code that would have to be entered each time.  You could name it something short like "FLC".  Here is a the code for a plugin that will take a string between the plugin tags and return the string in lower case.  I named it "lowcase", but you could change the name to something shorter.
It is only 8 lines, but I couldn't paste it here so I put it in pastebin:
http://pastebin.com/QYwPzgrc

Add it as /lib/wiki-plugins/wikiplugin_lowcase.php
Do not close the php tag.
If you do want to change the name to something shorter, it has to be changed in two places, in the program name and in the function name.
To use it:

Copy to clipboard
{LOWCASE()}{ {page}}{LOWCASE}

I hope that helps.

Tom


posts: 29

Thanks for your help.

The Smarty example worked like a charm! I added it to a content template I had created earlier. When setting up the wiki I created a wiki page, alphabetically tabbed, with each tab containing a table with a various number of page links. Now all I do is just click the link to create a new wiki page, apply the template, and add some additional content.

I've added your pastebin plugin as I might have a use for it. 

Thanks again for your help, Tom.

 


Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting