solved add content depending on the url

Nmaster88
Nmaster88
@nmaster88
10 years ago
94 posts
I'm trying to add some code to my header.tpl and footer.tpl depending on the page i'm in.

The code to do that is something like this:
{jrCore_module_url module="jrProfile" assign="murl"}
...
{if $current_url==$jamroom_url+"/"+$murl+"/settings/profile_id="+$_user.profile_id}
...
{/if}
for the footer i do the same, but it's not working!

If i had a static url, like this:
{if $current_url=="http://site.com/profile/settings/profile_id=121"}
It works.

Am i doing something wrong?

updated by @nmaster88: 06/20/16 06:01:26PM
paul
@paul
10 years ago
4,335 posts
Do the smarty concatenation in the URL like this -

{if $current_url == "`$jamroom_url`/`$murl`/settings/profile_id=`$_user.profile_id`"}

Note the use of the back-tics.

hth


--
Paul Asher - JR Developer and System Import Specialist

updated by @paul: 03/18/16 06:09:59AM
Nmaster88
Nmaster88
@nmaster88
10 years ago
94 posts
Doing that it works well on that case,
but i have another code i need to test if it's on a specific url and it's not working, this is the code:
<ul id="modulechoice" class="nav nav-tabs nav-white">
    {if isset($_items)}
        {foreach from=$_items key="module" item="entry"}

                {if $current_url=="`$jamroom_url`/`$_user.profile_url`/`$entry.module_url`"}
                    {if $current_url|@strstr:$entry.label ==true}
                        <li  class="active" id="{$entry.label}" >
                    {else}
                        <li  class="" id="{$entry.label}" >
                    {/if}
                {elseif $current_url=="`$jamroom_url`/`$_user.profile_url`"}
               
                    {if $entry@first}
                        <li  class="active" id="{$entry.label}" >
                    {else}
                        <li  class="" id="{$entry.label}" >
                    {/if}
                {/if}
                <a href="#{$entry.label}" data-toggle="tab" style="text-transform: capitalize;">{$entry.label}</a>

            </li>
        {/foreach}
    {/if}
</ul>
If i put a specific case like this:
{elseif $current_url=="http://site.com/artist/"}
and go to that artist page it works.
updated by @nmaster88: 03/18/16 01:47:47PM
michael
@michael
10 years ago
7,826 posts
if you want to use the same string over and over, assign it to a variable

This
{if $current_url=="`$jamroom_url`/`$_user.profile_url`/`$entry.module_url`"}
is the same as this:
{$new_url = "`$jamroom_url`/`$_user.profile_url`/`$entry.module_url`"}
{if $current_url == $new_url}

Then you can output {$new_url} just to check what it is:
new_url is: {$new_url}
current_url is: {$current_url}

helps to see if they are as you expect them to be.
Nmaster88
Nmaster88
@nmaster88
10 years ago
94 posts
What happened is that for different templates sometimes the smarty variables are not the same.
I had to use another ones.

Thanks both for the help!

Tags