Announcement

Collapse
No announcement yet.

Changing the header logo depending on the section/url

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lynne
    replied
    Your condition is not going to work. The first one says "if THIS_SCRIPT=='vbcms'" and that means ALL your CMS pages will use that condition. You need to rearrange them and think about the logic. I'd do the index page first, then all the vbcms/gets and then the final would just be if all else. Something more like this:

    HTML Code:
    <vb:if condition="THIS_SCRIPT == 'index'">
    <div class="footerForum">
    <vb:elseif condition="THIS_SCRIPT=='vbcms' AND $_GET['r'] == '122-advice'" />
    <div class="footerAdvice">
    <vb:elseif condition="THIS_SCRIPT=='vbcms' AND $_GET['r'] == '137-projects'" />
    <div class="footerProjects">
    <vb:elseif condition="THIS_SCRIPT=='vbcms' AND $_GET['r'] == '138-news'" />
    <div class="footerNews">
    <vb:elseif condition="THIS_SCRIPT=='vbcms' AND $_GET['r'] == '139-events'" />
    <div class="footerEvents">
    <vb:else />
    <div class="footer">
    </vb:if>

    Leave a comment:


  • andywoodrow
    replied
    Morning Lynne,

    Sorry, I misled a little. I'm not using $_GET['r'] on the Forum page, I'm still using THIS_SCRIPT == 'index'.

    I've just tried this to add vbcms to THIS_SCRIPT:

    Code:
    <vb:if condition="THIS_SCRIPT=='vbcms'">
    <div class="footer">
    <vb:elseif condition="THIS_SCRIPT == 'index'" />
    <div class="footerForum">
    <vb:elseif condition="$_GET['r'] == '122-advice'" />
    <div class="footerAdvice">
    <vb:elseif condition="$_GET['r'] == '137-projects'" />
    <div class="footerProjects">
    <vb:elseif condition="$_GET['r'] == '138-news'" />
    <div class="footerNews">
    <vb:elseif condition="$_GET['r'] == '139-events'" />
    <div class="footerEvents">
    </vb:if>
    But the Advice, Projects, News & Events (which are all vbcms content) is displaying the vbcms footer in the first argument.

    Leave a comment:


  • Lynne
    replied
    You cannot use $_GET['r'] on a forum page. You will need to create your condition in such a way that it makes sure to not check that for any pages except the CMS (THIS_SCRIPT=='vbcms', I believe).

    Leave a comment:


  • andywoodrow
    replied
    Hi Lynne,

    That's worked fine, but for some reason the forum page THIS_SCRIPT == 'index' is no longer working.

    This code, the forum displays OK (THIS_SCRIPT == 'index'), but the homepage ($_GET['r'] == '1') does not.

    <vb:if condition="$_GET['r'] == '1'">
    <div class="headerBarHome">
    <vb:elseif condition="THIS_SCRIPT == 'index'" />
    <div class="headerBarForum">
    <vb:elseif condition="$_GET['r'] == '122-advice'" />
    <div class="headerBarAdvice">
    <vb:elseif condition="$_GET['r'] == '137-projects'" />
    <div class="headerBarProjects">
    <vb:elseif condition="$_GET['r'] == '138-news'" />
    <div class="headerBarNews">
    <vb:elseif condition="$_GET['r'] == '139-events'" />
    <div class="headerBarEvents">
    </vb:if>
    This code, the homepage displays OK ($_GET['r'] == ''), but the Forum (THIS_SCRIPT == 'index') does not.

    <vb:if condition="$_GET['r'] == ''">
    <div class="headerBarHome">
    <vb:elseif condition="THIS_SCRIPT == 'index'" />
    <div class="headerBarForum">
    <vb:elseif condition="$_GET['r'] == '122-advice'" />
    <div class="headerBarAdvice">
    <vb:elseif condition="$_GET['r'] == '137-projects'" />
    <div class="headerBarProjects">
    <vb:elseif condition="$_GET['r'] == '138-news'" />
    <div class="headerBarNews">
    <vb:elseif condition="$_GET['r'] == '139-events'" />
    <div class="headerBarEvents">
    </vb:if>
    - - - Updated - - -

    Lynne,

    I *think* the CMS homepage and the forum.php pages are picking up the same:

    <vb:if condition="$_GET['r'] == ''">

    Just put this code in for the homepage, and the same results are being displayed when I displayed the forum.php page too.

    Any thoughts?

    Thank you.
    Andy

    Leave a comment:


  • Lynne
    replied
    For the forum.php page, just use THIS_SCRIPT in the condition - THIS_SCRIPT == 'index' . As for the homepage, do you mean the home CMS page? Then $_GET['r'] is either blank or it actually does have a section id, it is usually 1.

    Leave a comment:


  • andywoodrow
    replied
    Hi Lynne,

    That worked a treat, thankyou! However, neither the forum or my homepage has a section ID, so how do would I identify that page? This is my code:

    Code:
    <vb:if condition="$_GET['r'] == '122-advice'">
    <a href="/"><img class="logo" src="logo1.png" alt="" /></a>
    <vb:elseif condition="$_GET['r'] == '137-projects'" />
    <a href="/"><img class="logo" src="logo2.png" alt="" /></a>
    <vb:elseif condition="$_GET['r'] == '138-news'" />
    <a href="/"><img class="logo" src="logo3.png" alt="" /></a>
    <vb:elseif condition="$_GET['r'] == '139-events'" />
    <a href="/"><img class="logo" src="logo4.png" alt="" /></a>
    </vb:if>
    I've tried adding a query string and using this as the ID identifier but that doesn't work.

    Thanks Lynne.

    Leave a comment:


  • Lynne
    replied
    It looks like intval is not allowed in html conditions, so you will need to use just $_GET['r'].

    Leave a comment:


  • andywoodrow
    replied
    Hi Lynne,

    Sorry I got this error. I'm not to say my syntax is correct though

    The following error occurred when attempting to evaluate this template:
    Could not find phrase ' The following template conditional expression contains function calls:

    <if condition="(intval($_GET['r']) == Home">

    Function Name Usage in Expression
    intval intval($_GET['r'])
    With a few exceptions, function calls are not permitted in template conditional expressions. Please go back and re-write this expression.

    The following functions are allowed in template conditional expressions:
    in_array() is_array() is_numeric() isset() empty() defined() array() gmdate() mktime() gmmktime() can_moderate() can_moderate_calendar() exec_switch_bg() is_browser() is_member_of() is_came_from_search_engine() vbdate()'.
    This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
    I'm using this syntax:
    Code:
    <vb:if condition="(intval($_GET['r']) == Home">
    <a href="/"><img class="logo" src="image-source.png" alt="" /></a>
    <vb:else />
    <a href="/"><img class="logo" src="alt-image-source.png" alt="" /></a>
    </vb:if>

    However, ideally I would like to use a statement that will look at the URL pattern as not all my pages will be in sections:

    Leave a comment:


  • Lynne
    replied
    Originally posted by andywoodrow View Post
    Hi Lynne,

    Thank you. I can't seem to find any template conditions to display depending on the URL or regexp of a URL. I've posted a reply on the article. Thank you.

    Andy
    You said it was based on the section, so most likely it is $_GET['r'] you will look at - if (intval($_GET['r']) == xx) - where xx is the section id.

    Leave a comment:


  • Mark.B
    replied
    In vBulletin you are better doing it off the script name, or off things like the forumid.

    Depends what you're actually after, but for example:

    Code:
    <vb:if condition="THIS_SCRIPT == 'showthread'">LOGO HERE</vb:if>
    Would give you a banner/logo that only displays when viewing a thread.

    Code:
    <vb:if condition="THIS_SCRIPT == 'showthread'">FIRST LOGO HERE<vb:else />SECOND LOGO HERE</vb:if>
    Would give you FIRST LOGO if viewing a thread, but SECOND LOGO everywhere else.

    In simple form you can do that in the templates. If it's going to get complex you can do much the same thing via a plugin, set a variable that stores the image path based on your chosen conditions, register that variable and stick it in the header!

    But, I think I've just strayed into vbulletin.org territory there!

    Leave a comment:


  • andywoodrow
    replied
    Hi Lynne,

    Thank you. I can't seem to find any template conditions to display depending on the URL or regexp of a URL. I've posted a reply on the article. Thank you.

    Andy

    Leave a comment:


  • Lynne
    replied
    You may use regular template conditions to do what you want. If you go over to vbulletin.org, the modification site, and click on the Articles tab and then the vB4 section, you will find an article on template conditions.

    Leave a comment:


  • Changing the header logo depending on the section/url

    Hi,

    I have a request to change elements of the header (logo and background colour) depending on the url/section the visitors is on.

    I have on header template and would like to know how to either a) change the header template depending on what the url section is or b) enable PHP so that I can wrap some logic to display a different logo depending on the URL).

    Can anyone help me please?

    Thanks.
    Andy

Related Topics

Collapse

  • arisythila
    Change logo URL
    by arisythila
    Hello, Took some gandering around, and cannot seem to find it.

    I am trying to change where you go if you click the main logo. We want our users to go to our main wordpress URL instead of...
    Tue 3 Jun '14, 10:00am
Working...
X