View previous topic :: View next topic |
Author |
Message |
emichaud Smarty Rookie
Joined: 28 Jan 2005 Posts: 5
|
Posted: Fri Jan 28, 2005 3:50 am Post subject: custom directory for plug-ins and add-on's for postnuke |
|
|
Hi, thanks for smarty.
I'm working on a module for postnuke that I want to distribute. Postnuke .750 now uses smarty as default and includes a wrapper and api for it. They did a nice job.
Now my question. I want to use smarty_validate and other add on's in my module, but I cannot be sure that future users will have the classes installed.
I'd like to install them in my module subdirectory and have my code use the default postnuke smarty, but have my code use plug-in's from my module directory. I know that smarty will always be available, but I don't want to ask people to install all the add on's in the system directories, just for my module.
I'd appreciate your recommendation on how to set this up.
thanks! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Jan 28, 2005 2:47 pm Post subject: |
|
|
append your plugin directory to the smarty plugins_dir array. |
|
Back to top |
|
emichaud Smarty Rookie
Joined: 28 Jan 2005 Posts: 5
|
Posted: Fri Jan 28, 2005 6:23 pm Post subject: help with syntax |
|
|
thanks for the start. could you give me the syntax for that?
also, are there any known issues using validate with the postnuke pnRender stuff? I had a couple of issues and not sure if they are related. I'll post more details about those after I get a chance to troubleshoot a bit and be sure what I'm talking about.
thanks so much ... |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Jan 28, 2005 7:24 pm Post subject: Re: help with syntax |
|
|
emichaud wrote: | could you give me the syntax for that? |
$smarty->plugins_dir[] = '/path/to/my/plugins';
emichaud wrote: |
also, are there any known issues using validate with the postnuke pnRender stuff? |
I don't know anything about postnuke or its smarty implementation. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Jan 29, 2005 1:00 am Post subject: |
|
|
I don't know if it is that easy. While you will gain access to the plugins using this method, the addon component classes are a bit trickier since (at least in the case of SmartyValidate) they typically require a reference to the running Smarty. So if you are aiming to do a straight plugin module for PN, it will require some additional setup within PN to accomodate it as the reference must be acquired before the rendering process begins (ie. outside of the template)
I handle things like this in my extended Smarty class but from what I gather from your post and a little poking around the PostNuke cvs is that the Smarty class is managed by another PN class. This shouldn't be too difficult but from what I gathered in my cursory look, this would preclude it from being a pure plugin (?).
Another thing I noticed was that PN seems to have some sort of variable validation system already in-place. Is that not suitable to use instead? |
|
Back to top |
|
emichaud Smarty Rookie
Joined: 28 Jan 2005 Posts: 5
|
Posted: Sat Jan 29, 2005 9:51 pm Post subject: Hi Thanks for the syntax and the response. |
|
|
I'm going to test it tonight to see if it will work as I hope. PostNuke uses a pnRender - some custom work that is subclassed to smarty.
I don't fully understand pnRender yet, but I think you have the option of using any pnRender functions or any of smarty. pnRender enables smarty and comes with PostNuke. At least one reason they built it that way was to provide a portable templating system that did not require the isp to have smarty or any specifc version, etc.
I am having an initial problem however with validating. It seems to always fail. Here is a bit of testing code I'm using to try and isolate this:
Code: |
if(SmartyValidate::is_valid($_POST)) {
// no errors, done with SmartyValidate
SmartyValidate::disconnect();
pnSessionSetVar('errormsg', pnVarPrepHTMLDisplay("VALIDATED"));
return;
} else {
// error, redraw the form
pnSessionSetVar('errormsg', pnVarPrepHTMLDisplay("DID NOT VALIDATE"));
return print_R($_POST);
} |
I'm posting a form with only one validation check - a notempty rule. I make sure the field has data and then submit. It fails then returns the _Post array, which also shows that the variable name is correct and that it has data.
I'm going to post on the PN site also. I'll let you know if the directory plug-ins work.
thanks |
|
Back to top |
|
emichaud Smarty Rookie
Joined: 28 Jan 2005 Posts: 5
|
Posted: Sat Jan 29, 2005 11:54 pm Post subject: figured out the validate issue |
|
|
I got the validate working. I took a look at the session variables and it was holding an old validate statement in the session. let me explain:
I ran the example using the validate "FullName". Then I changed it to match up with the actual variables in my form - "ball_name". When I validated, it kept failing. The reason was because the validate rule for "FullName" was still in the session. Odd.
Postnuke keeps persistent sessions for logged in users. I cleared the session by logging off then back in, and voila - the validate function worked as expected.
I'm not sure why FullName stayed in the session though, I would have thought it would have been removed. Maybe I didn't use the disconnect correctly.
I have another question: Is there a way to control where the error message prints when you re-post the form? I'd like to do something like this:
<td>Ball Name</td>
<td>
<input name=ball_nane>
{if error:}
{<b>ERROR MESSAGE HERE<B>}
(end if}
</td>
thanks for any help! |
|
Back to top |
|
|