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.

How to add class to a href in Vanilla 2.0.18.2?

remesloremeslo
edited July 2013 in Vanilla 2.0 - 2.8

Hello!
How I can add class to a href link? For instance I put <?php echo $this->Pager->ToString('more'); ?> to my views/duscussion/index.php

And now I get such html:

<div class="P"><div id="PagerAfter" class="Pager NumberedPager">
<a href="/index.php?p=/discussion/2/ironman-movie/p1" class="Previous">‹</a>
<a href="/index.php?p=/discussion/2/ironman-movie/p1">1</a>
<a href="/index.php?p=/discussion/2/ironman-movie/p2" class="Highlight">2</a>
<span class="Next">›</span></div></div>

How I can add class "myNew" to get result such

<a href="/index.php?p=/discussion/2/ironman-movie/p1" class="myNew>1</a> ?

Comments

  • Vanilla 2.0.18.2?

    You need to update to 2.0.18.8 for security issues.

    Where would you plan on adding this link with class?

    to add a link to a default.master.php

    <?php $this->Menu->AddLink('New Discussion', T('New Discussion'), 'post/discussion', array('class'=>'your class'));?>
    

    Depending on where , or what order you put those , you will get varied results. But that is basically what a php link looks like.

  • Sorry.
    I plan add this class into every $this->Pager links.
    Its possible?

  • I would guess that the concept applies , you can test one and see if it works , the structure would be the same but instead of menu it's pager, you could also look into using jquery to give the .attribute class I suppose, To those links not necessarily from the pager.

    you would add array('class'=>'your class') to the pager links . However sometimes adding class this way will make the links not show unless logged in.

  • Awesome p! I am stealing that bit!! I'm going to class it up now!!!

  • peregrine, you are magician!!
    and this simple and beauty code is - pure magic!!
    THANK YOU!!

  • peregrineperegrine MVP
    edited July 2013

    poof! gone!

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • why do you need to an a class? what is wrong with the existing selectors. I'm not saying it is wrong, but what is the application? You probably would be able to narrow it down just by selectors, if it is not a fleeting case.

    grep is your friend.

  • @x00 said:
    why do you need to an a class? what is wrong with the existing selectors. I'm not saying it is wrong, but what is the application? You probably would be able to narrow it down just by selectors, if it is not a fleeting case.

    that's what I was wondering too. but maybe it was too execute some other php code based on class rather than a css change.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.