Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Menu ... question
422
MVP
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.
There was an error rendering this rich post.
Tagged:
0
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:
I nearly have this @Todd.
I have.
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
There was an error rendering this rich post.
Yeah, just put the actual html in your theme. You don't have to do
$this->Menu->AddLink(...)
.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(); } ?>
There was an error rendering this rich post.
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...
There was an error rendering this rich post.
Strike the above , am handling another way.
There was an error rendering this rich post.
Okay, but you know that you can always break out of php blocks and go back into them? That's a php fundamental.