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
Answers
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:
- Spam
- Abuse
- Troll
1 • Off Topic Insightful 1Awesome LOL •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
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Yeah, just put the actual html in your theme. You don't have to do
$this->Menu->AddLink(...).- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Strike the above , am handling another way.
422 Real Estate Australia , now open Check it out
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Okay, but you know that you can always break out of php blocks and go back into them? That's a php fundamental.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •