Jump to content

Can PHP code be used in template files?


Recommended Posts

Guest eric47905

Im not sure if I am much help on your answer here, but I know you can do javascript and html obviously in the template files. But as far as the php, I think it would if at worst be better to code in the .inc.php file and just call to it as the rest of the items do in the template.

At least that way, even if it could work in the template file (which I dont know if it can or if it cant, but I think the template file just gets called up as an html file in essence, and all the functionality is referenced to the php files in the background) you would have all of the real coding seperated making it easier to go back later and work on. That way the templates would stay as pure templates and code would be where the rest is.

Sorry if that doesnt help you

Link to comment
Share on other sites

The documentation for the template engine can be found at:

http://www.phpxtemplate.org

It looks pretty powerful stuff.

In fact, I've just uploaded the new class (0.4.0 to see if it works - CubeCart is using an old version), and all is fine.

Not too sure if there is much difference (speed or features), the file is larger, but it looks to have much more comments than the old file.

Jason

Link to comment
Share on other sites

Thanks all - any idea about how to accomplish to following:

I want to set the class of an <li> in a menu file based on a variable, so that I can create an expandable menu (which expands based on the category being viewed.....). Normally I would do it like this:

<li class="<?php echo($pagetype;) ?>"><a href=".....catid=15">page name</a></li>. I haven't quite been able to figure out how to integrate the inc.php files with the template files....

I have seen the quickie tutorials, but they just reference calling the template from the inc.php file and the index.php file.... I need to figure out how to integrate the two. the inc.php files don't seem to use any html at all..... and the template files dont' use php, so I need to figure out how to strip the php out of the html in the statement above, or how to put the html into the inc.php file.....

Any one willing to help? thanks again.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...