I have a requirement for two functions that determine similar user status information to the functions used to display the "Login"/Logout" link and the "Create free account/Your Profile" link in many themes. In my case they are membership related.
You can see what I'm talking about by looking at the top of my website where you'll see something like :
[ Create free account | Join the Club | Log-in ]
I currently have two new functions appended to the /includes/pnUser.php file and the "Join the Club" bit is determined by a return from one of these.
I'm also in the process of upgrading from 0.750 to 0.762 and wondered whether there's a better way than substantially adding to this core PN file (which I realise is generally discouraged) so I don't need to tweak too much when I upgrade every time.
Would it be better to seperate my two functions out to a new /includes/membership.php file and then include that from pnUser.php or are their even better ways to achieve what I want?
A block is not the answer BTW or if it is you could argue that the current "create account/login/logout/your profile" functions should also be part of a block.
- jmvaughn created topic »TagIt 3.0 for Zikula« 09:34 AM
- jmvaughn responded to »Shoutit for zikula 1.3?« 09:31 AM
- mdee responded to »Different page content under one template (tpl file) based on URL« 07:17 AM
- Guite responded to »Remove contents of nuke_sc_anticracker from Database« 01:30 AM
- espaan responded to »Categories disappear when editing ...« 08. Feb
- eledril responded to »How decrease zikula cpu usage« 08. Feb
- jmvaughn responded to »PN 0.764 to Zikula 1.1.2 (migration) Internal Server Error« 08. Feb
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
A better way to modify core files? /includes/pnUser.php
-
- Rank: Softmore
- Registered: May 25, 2004
- Last visit: Oct 21, 2009
- Posts: 192
-
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
A smarty plugin would probably be the best way - assuming that your theme is a xanthia based one. You then just drop the plugin tag into the theme template(s) where you want the output to appear.
-Mark
--
Visit My homepage and Zikula themes. -
- Rank: Softmore
- Registered: May 25, 2004
- Last visit: Oct 21, 2009
- Posts: 192
-
- Rank: Expert
- Registered: Dec 02, 2002
- Last visit: Apr 30, 2010
- Posts: 1474
Why not create a simple module to house your additional functions?
-Lobos
--
-Lobos
Professional PHP Framework Services: Concept, Development and Deployment -
- Rank: Softmore
- Registered: May 25, 2004
- Last visit: Oct 21, 2009
- Posts: 192
I already have a complicated module that these particular functions are used in relation to.
I already use two Smarty plugins:
/modules/pnRender/plugins/function.pnusermemberstatus.php
to see simply whether somebody is a member or not (I use this in my HTML module templates to only show members member stuff) and
/modules/Xanthia/plugins/function.membershiplinks.php
to determine the actual membership status and generate the links this particular thread started off talking about.
I think what I need to know is; in a Smarty plugin how do I call a function from a PHP script that's not part of the PN core like pnUser.php
Is it simply a case of including:
Quote
include("/modules/Membership/newFunctions.php");
at the start of my plugin?
While we're on it, what's the difference between the pnRender and Xanthia plugin directories? -
- Rank: Expert
- Registered: Dec 02, 2002
- Last visit: Apr 30, 2010
- Posts: 1474
Quote
Is it simply a case of including:
yes, but if the functions are loaded already you will get an error.
Quote
While we're on it, what's the difference between the pnRender and Xanthia plugin directories?
It is my opinion that pnRender plugins are for core and module functionality whilst xanthia plugins are concerned with theme related functionality.
-Lobos
--
-Lobos
Professional PHP Framework Services: Concept, Development and Deployment -
- Rank: Legend
- Registered: Dec 11, 2002
- Last visit: Oct 21, 2009
- Posts: 11674
I take it then that your module isn't API compliant - because this would make it easier.
Anyway, include_once('/modules/Membership/newFunctions.php'); will do the trick.
--
itbegins.co.uk - Zikula Consulting
birtwistle.me.uk - Personal Blog
Please read the Support Guide -
- Rank: Team Member
- Registered: Mar 18, 2002
- Last visit: Oct 21, 2009
- Posts: 6606
I agree with Lobos. These functions belong in the module getting called using pnMod(API)Func - this is, after all, the point of having a module based system. Perhaps your API functions might actually be useful elsewhere too?
The difference between the two plugin directories is now a little arbitrary but originally the idea was that the Xanthia (now Theme) plugins directory would be plugins for use in theme templates (for example those that generate dynamic values for the header ->) where as those in pnRender would be plugins that interfaced to the pnAPI or other core functionality. The boundaries have blurred quite considerably since we introduced XTE and there are some good arguments for simply putting these two directories together.
Additional .8x note. In this release you also have a plugins directory in /config/plugins. This can be used to hold your own site wide plugins without having to add them to either the Xanthia (Theme) or pnRender modules.
-Mark
--
Visit My homepage and Zikula themes. -
- Rank: Softmore
- Registered: May 25, 2004
- Last visit: Oct 21, 2009
- Posts: 192
HammerHead
I take it then that your module isn't API compliant - because this would make it easier.
Anyway, include_once('/modules/Membership/newFunctions.php'); will do the trick.
My module is API compliant. I think my original problem was that I was trying to duplicate functionality held in a core module, so just added it to the end of that core module.
I'll have a play over the next few days and post the solution here for future reference.
Thanks for all the assistance. -
- Rank: Softmore
- Registered: May 25, 2004
- Last visit: Oct 21, 2009
- Posts: 192
Here's what I did and why.
I wanted to remove some changes I'd made to the core file /includes/pnUser.php to support some Xanthia plugins used in my templates and by the HTML module (i.e. not just used by the module to which they relate). This would make my upgrade route from .750 to .762 and beyond easier.
I removed the functions from /includes/pnUser.php and placed them in the pnuserapi.php script for "mymodule" to which they relate. I had to rename them to fit in with the standards of my API module.
Then I changed the plugins to include the following:
Quote
if ( pnModAvailable('mymodule') ) {
pnModAPILoad('mymodule','user');
$result=pnModAPIFunc('mymodule','user','myfunction');
} else {
$result='nomod';
}
I left the two plugins where they were. One in /modules/pnRender/plugins as it's used by the HTML Module and one in /modules/Xanthia/plugins as it's used by my site's theme. It sounds like it doesn't really matter where they are, as long as I remember to put them back after an upgrade. To this end I'd highly recommend anybody who dabbles to make sure each changed/new file contains your name so you can find them it easily. I just used an elaborate find/grep combo ;)
When .8 comes along I guess I can move my plugins into the new /config/plugins directory.
edited by: dunx, May 02, 2006 - 10:36 PM
- Moderated by:
- Support
