Jump to content

Conditionally Inject PHP into TPL File


Chance

Recommended Posts

Hi,

 

I am trying to put a single line of code into my header.tpl file so that on every page EXCEPT index.php, the breadcrumb nav links are shown.

 

In the header.tpl file, I have the following in the area where the breadcrumbs are to be shown:

 

{php} if($_SERVER["PHP_SELF"]!="/index.php") echo("Test"); {/php}

 

This code does work and I do see the word 'Test' on every page except the home page, just as I want. But when I try to substitute the echo("Test"); for {$breadcrumbnav} nothing renders, which means my code does not work.

 

Anyone know what I am missing? It is probably something very simple but I cannot find it.

 

I have tried echo("{$breadcrumbnav}"); as well and no errors but no output of bread crumbs either.

 

I do not think it is necessary to have the bread crumb trail on the home page of the client portal area so I am trying to eliminate it on that page only.

 

Any input would be greatly appreciated. Is there an equivalent in smarty for determining the name of the current php script being executed?

Link to comment
Share on other sites

Man, it helps to read the documentation. I came across a snippet of smarty syntax for accessing server side variables, and just put two and two together. Here is the super simple solution to my problem and it works like a charm!

 

{if $smarty.server.SCRIPT_NAME neq "/index.php"} {$breadcrumbnav} {/if}

 

How easy was that!?!

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