- Moderated by:
- Support
-
- rank:
-
Freshman
- registered:
- November 2002
- Status:
- offline
- last visit:
- 06.12.07
- Posts:
- 37
In the old style themes, it was possible to include self-defined commands into includes/commands.inc.php. I added a command named statusmsg like this:Code
$command['[statusmsg]'] =
'StatusMessage(pnSessionGetVar("errormsg"), pnSessionGetVar("statusmsg"));
pnSessionDelVar("errormsg"); pnSessionDelVar("statusmsg");'
Now I would like to implement the same in my new Xanthia compatible theme, but I can't find a place where I can define myself the theme commands. I tried to add my command into the Xanthia module directory (plugins) into a file function.statusmsg.php, but without success: it doesn't load it. What can I do to add my command?
Furthermore there is one more confusing thing: in all Xanthia themes in the file templates/modules/news/newsusermenu.htm markwest included a command named [pngetstatusmsg], but in no place it appears as a definition. -
- rank:
-
Moderator
- registered:
- March 2002
- Status:
- offline
- last visit:
- 26.08.08
- Posts:
- 7720
A couple of things to note here...
1) the templates in templates/modules/news are for the .8x news module not the .7x one. Xanthia and the themes is built under .8x and backported to .7x. The news module templates are .7x are News-index.htm and News-article.htm in the main theme templates directory.
2) You author you own theme commands by writing Smarty plugins and placing them in <themename>/plugins. Smarty plugins follow a set pattern in the function name and filename. See the Smarty docs for more info on writing plugins.
3) There are a number of places that Xanthia will load plugins from. Firstly the pnRender plugins directory (modules/pnRender/plugins), the xanthia plugin directory (modules/Xanthia/plugins) and the theme (themes/<themename>/plugins).
The pngetstatusmsg plugin is a standard pnRender plugin and is found in modules/pnRender/plugins.
Hope this helps.
-Mark</themename></themename> -
- rank:
-
Freshman
- registered:
- November 2002
- Status:
- offline
- last visit:
- 06.12.07
- Posts:
- 37
Mark, thank you for your reply. However I still have some confusion, and more of it after studying the Smarty docs. They say that "Smarty will output appropriate error messages if the plugin file it needs is not found, or if the file or the plugin function are named improperly." However in my case it doesn't process the function call at all, being it called (say it is "getstatusmsg") like this: {getstatusmsg} (as shown here) or like this (as shown in the examples). Furthermore, the Smarty doc says that a plugin is loaded automatically but can also be registered... when or where does it have to be registered? Do I have to register it in <themename>/theme.php or <themename>/xaninit.php or where else?
Besides... being pngetstatusmsg a standard plugin, shouldn't it be called anyway, without registering?
Thank you very much for your help!</themename></themename> -
- rank:
-
Moderator
- registered:
- March 2002
- Status:
- offline
- last visit:
- 26.08.08
- Posts:
- 7720
You don't have to worry about registering plugins. This is fractionaly faster but needs to be done in PHP. When Smarty says the plugins are dynamically loaded it means that if a plugin is used in a template then this will be loaded automatically.
The difference in the {} and is that the delimiters used by Smarty are configurable. We use where as {} are the Smarty defaults.
The naming of plugins and the functions is crucial. If your plugin is function.getstatusmsg.php then the function inside the file must be name smarty_function_getstatusmsg otherwise nothing will happen.
Also it would help if you actual say what your trying to achieve. It's difficult to help when I don't know what your trying to achieve.
-Mark -
- rank:
-
Freshman
- registered:
- November 2002
- Status:
- offline
- last visit:
- 06.12.07
- Posts:
- 37
Mark, thank you again for that information. Now it works flawlessly. The modules I have coded all make heavy use of statusmessage (for errors in forms etc), so I simply wanted to show both statusmessage and errormessage on every page when it has been set, so that I don't have to build this function into every module. It had worked perfectly in my old theme, but I had trouble porting it to the new one. Now it works, and my porting is complete - now I'm Xanthia compatible (or better: my site is)! :D
Ah yes, one of the reasons I need it on every page is that I coded my own user management module that (besides other functions) shows the login confirmation ("Logging you in, hang tight") as status message. I didn't like that page that shows one line and then reloads the page ;)
