Jump to content

including a .tpl into a template file


peak

Recommended Posts

I am attempting to include a template file into an existing .tpl file.

I want to add a navigation on the side of a.tpl page that is a file call side-nav-login.tpl. I want to edit my side navigation in only 1 file, as opposed to on each of the many template pages, and I want to make use of the smarty shortcuts.

 

I have tried, as per smarty's suggestion, and it doesn't work. I have also tried the full url, which also doesn't work.

{include file='side-nav-login.tpl'}

 

and I have also included a new php file that contained the file side-nav-login.tpl, but the php file showed the header and footer also, instead of just showing the template content.

 

So I either want to reference a tpl file inside another tpl file, or get the php file to rid itself of the header and footer and only show the contents side-nav-login.tpl file.

 

thanks in advance for any suggestions.

Link to comment
Share on other sites

I thought I mentioned in my inital posting that I tried just that

 

"I have tried, as per smarty's suggestion, and it doesn't work. I have also tried the full url, which also doesn't work.

{include file='side-nav-login.tpl'}"

 

and it didn't work, but thank you!

Link to comment
Share on other sites

That's definitely a solution, but my main goal was to have one external navigation file that I edited, in lieu of having to edit all the files! I also wanted to have an external file that would make use of the smarty variables.

Link to comment
Share on other sites

Just a thought...

 

1. Make a tpl called navagtion.tpl where you would have your navigation.

 

2. In this file you would add all the for all the pages

{if $pagetitle == 'Shopping Cart' || $pagetitle == 'Order' || etc..}Navi Code Here {/if}

 

3. Delete the default WHMCS menu and add use

{include file='path/to/[color=red]navigation.tpl[/color]'}

 

Would this work?!!

Link to comment
Share on other sites

I just can't get the include to work with the .tpl, if I could, that woudl be great!! For some reason, my site just will not recognize "{include file='path/to/navigation.tpl'}" I have tried every path combo, single quotes, double quotes...but nothing is recognized once the site is uploaded, and I am not sure why it seems to work for everyone else!!! I have gotten the php include to work, but the .tpl doesn't!!

Link to comment
Share on other sites

you are correct, I wasn't adding that path, but it didn't work either!!!

 

I tried all combinations of this

 

{include file='/home/jazinta/public_html/billing/whmcs/templates/side-nav-login.tpl'}

 

with single quotes, double quotes, adding backslashes, removing backslashes, nothing will yield a result!

 

can anyone see what I am doing incorrectly?

Link to comment
Share on other sites

FYI!!! This is the syntax that finally yielded results!! YAY!!!!

 

{include file='file:/home/jazinta/public_html/billing/whmcs/templates/default/side-nav-login.tpl'}

 

The key is apparently the " file='file: " part of that equation.

Link to comment
Share on other sites

you are correct, I wasn't adding that path, but it didn't work either!!!

 

I tried all combinations of this

 

{include file='/home/jazinta/public_html/billing/whmcs/templates/side-nav-login.tpl'}

 

with single quotes, double quotes, adding backslashes, removing backslashes, nothing will yield a result!

 

can anyone see what I am doing incorrectly?

 

{include file='whmc/navigation.tpl'} 

 

Don't use the full server path.

Link to comment
Share on other sites

  • 1 month later...

Hi, just thought I'd add a little to this.

 

the syntax i used was {include file='<template name without the brackets>/<menu>.tpl'}, which worked fine.

 

I was having speed problems with page transitions on my site. So implemented the above and seems to have dealt with the page loading delays (only .5 second but every bit helps).

 

Now each page doesn't look like it complete reloads.

Cheers

Link to comment
Share on other sites

FYI!!! This is the syntax that finally yielded results!! YAY!!!!

 

{include file='file:/home/jazinta/public_html/billing/whmcs/templates/default/side-nav-login.tpl'}

 

The key is apparently the " file='file: " part of that equation.

Yes that's correct for an absolute path.

For it to work the other way the path is relative to the Smarty root (WHMCS root) so

{include file='/templates/default/side-nav-login.tpl'}

should work also.

Link to comment
Share on other sites

Thought I had better correct this.

In your case you can either use the full path with file='file: but try not to use the full path. Files included in a .tpl file is relative to the whmcs/templates directory so the correct way is:

 

{include file='default/side-nav-login.tpl'}

 

This from the Smarty Manual

Resources

The templates may come from a variety of sources. When you display() or fetch() a template, or when you include a template from within another template, you supply a resource type, followed by the appropriate path and template name. If a resource is not explicitly given the value of $default_resource_type is assumed.

 

Templates from $template_dir

Templates from the $template_dir do not require a template resource, although you can use the file: resource for consistancy. Just supply the path to the template you want to use relative to the $template_dir root directory.

 

Sorry for the incorrect info the first time.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated