Fork me on GitHub
Current releases are 2.1 (gold) and 2.0.18.11 (security patch for 2.0)
Ready for 2.1? Find out if your favorite plugins are compatible.
The 2.0 branch will no longer receive updates after Dec 2014.

Menu ... question

422422 Developer MVP
edited December 2011 in Vanilla 2.0 Help

Not massively competent as yet with Vanilla Core. But I do have a quetion.

I need to add menu item, now this I can do quite easily. But ...

The menu item needs to have an id.

Its format is in plain html ..

< a id="aTag" href="javascript:toggleText();" >Hide Slideshow< /a >

Any ideas on best practice to do this, and I really do not wish to edit this to config files.. because this is for a theme I am producing for sale.

422 Real Estate Australia , now open Check it out

Tagged:

Answers

  • ToddTodd Chief Product Officer Vanilla Staff

    I'd just put the html as you want it right into the default.master.tpl. If you want an option that's only visible to signed in users you can do something like:

    {if $User.SignedIn}
      ....
    {/if}
    
    422
  • 422422 Developer MVP
    edited December 2011

    I nearly have this @Todd.

    I have.

    $this->Menu->AddLink('Hide Slideshow', T('Hide Slideshow'), 'javascript:toggleText()', FALSE, array('id' => 'aTag'));

    Added in default.master.php

    The issue I have is the link needs to be just : javascript:toggleText()

    But it is prepending the site link Before the toggle... so the href should be:

    href="javascript:toggleText()"

    instead in firebug I see ..

    href="http://domain.com/javascript:toggleText()"

    Any ideas where I am going wrong please or please if @Tim could assist

    422 Real Estate Australia , now open Check it out

  • ToddTodd Chief Product Officer Vanilla Staff

    Yeah, just put the actual html in your theme. You don't have to do $this->Menu->AddLink(...).

  • 422422 Developer MVP
    edited December 2011

    Tried that but menu, is within a php block. Lol this is driving me mad... Dont even get me on next question.. Of toggle state cookies......Will post my codeblock.

    <?php $Session = Gdn::Session(); if ($this->Menu) { $this->Menu->AddLink('Dashboard', T('Dashboard'), '/dashboard/settings', array('Garden.Settings.Manage')); // $this->Menu->AddLink('Dashboard', T('Users'), '/user/browse', array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete')); $this->Menu->AddLink('Activity', T('Activity'), '/activity'); $this->Menu->AddLink('Hide Slideshow', T('Hide Slideshow'), 'javascript:toggleText()', FALSE, array('id' => 'aTag')); if ($Session->IsValid()) { $Name = $Session->User->Name; $CountNotifications = $Session->User->CountNotifications; if (is_numeric($CountNotifications) && $CountNotifications > 0) $Name .= ' '.$CountNotifications.''; if (urlencode($Session->User->Name) == $Session->User->Name) $ProfileSlug = $Session->User->Name; else $ProfileSlug = $Session->UserID.'/'.urlencode($Session->User->Name); $this->Menu->AddLink('User', $Name, '/profile/'.$ProfileSlug, array('Garden.SignIn.Allow'), array('class' => 'UserNotifications')); $this->Menu->AddLink('SignOut', T('Sign Out'), SignOutUrl(), FALSE, array('class' => 'NonTab SignOut')); } else { $Attribs = array(); if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE) $Attribs['class'] = 'SignInPopup'; $this->Menu->AddLink('Entry', T('Sign In'), SignInUrl($this->SelfUrl), FALSE, array('class' => 'NonTab'), $Attribs); } echo $this->Menu->ToString(); } ?>

    422 Real Estate Australia , now open Check it out

  • 422422 Developer MVP

    If I add html : like. <a id="aTag" href="javascript:toggleText();">Hide Slideshow</a>

    Before starting php tag , it displays ( but obviously dont want it there )

    If I add it after the final ?> it doesnt display...

    422 Real Estate Australia , now open Check it out

  • 422422 Developer MVP

    Strike the above , am handling another way.

    422 Real Estate Australia , now open Check it out

  • ToddTodd Chief Product Officer Vanilla Staff

    Okay, but you know that you can always break out of php blocks and go back into them? That's a php fundamental.

    $Session = Gdn::Session();
    if ($this->Menu) {
       ?><b>Wow, I can type html!!!</b><?php
       ...
    }
    
Sign In or Register to comment.