Welcome Guest, Not a member yet? Register   Sign In
add a class to an achor tag
#1

[eluser]ChristopherDosin[/eluser]
i didnt found something in the user guide.
how can i add an ID or CLASS to an achor tag?
#2

[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...elper.html

Quote:The third parameter can contain a list of attributes you would like added to the link. The attributes can be a simple string or an associative array.

Code:
echo anchor('link/to/file', 'A Link', array('class' => 'my_class'));
#3

[eluser]ChristopherDosin[/eluser]
ah thanks so much Smile

and one more question i dont know if its possible.

i need a <span> in my anchor tag

so
Code:
<a href="#" class="myclass"><span>Link</span></a>

is this possible?
#4

[eluser]elaniobro[/eluser]
This should help you with a majority of questions you have now, and or will have.

Code:
&lt;?= anchor('/thoughts/more/'.$row->id,
                                img(array(
                                          'src'=>'img/thoughts/readmore_a.jpg',
                                          'id'=>'readMore'.$count,
                                          'border'=>'0',
                                          'alt'=>'Read More'
                                          )
                                    ),
                                array(                                          
                                      'onmouseover'=>'readMore'.$count.'.src='."'".base_url().'img/thoughts/readmore_b.jpg'."'".';'.'"',
                                      'onmouseout'=>'readMore'.$count.'.src='."'".base_url().'img/thoughts/readmore_a.jpg'."'".';'.'"',
                                      'class'=>'readMore-link'
                                      )
                                );
?&gt;

and to answer your question this should work (I have not tested it):
Code:
&lt;?= anchor('http://www.example.com',
                                '<span>hi</span>',
                                array(                                            
                                      'class'=>'readMore-link',
                                      'target'=>'_blank'
                                      )
                                );
?&gt;
#5

[eluser]ChristopherDosin[/eluser]
thanks so much

Code:
&lt;?=anchor('portfolio/details/'.$row->id, '<span>Details</span>', array('class' => 'button_link', 'title' => 'Details'));?&gt;

now it`s working Smile
#6

[eluser]Phil Sturgeon[/eluser]
Code:
<a href="&lt;?=site_url('portfolio/details/'.$row-&gt;id);?&gt;" class="button_link" title="Details">
    <span>Details</span>
</a>

Don't over-complicate something that should be simple. :-)
#7

[eluser]ChristopherDosin[/eluser]
[quote author="Phil Sturgeon" date="1268412088"]
Code:
<a href="&lt;?=site_url('portfolio/details/'.$row-&gt;id);?&gt;" class="button_link" title="Details">
    <span>Details</span>
</a>

Don't over-complicate something that should be simple. :-)[/quote]

ohhh great Big Grin

thank you very much for this tip Wink
#8

[eluser]elaniobro[/eluser]
While that may be true, I've found that in IE8, doing the basic <a > rollover using javascript does not work, yet alone show an image unless you put it in the anchor(). Maybe not the case for you but it certainly was for me.

It's also good practice at getting used to coding in PHP to use the functions and arrays, it has helped me immensely.
#9

[eluser]danmontgomery[/eluser]
[quote author="elaniobro" date="1268429942"]While that may be true, I've found that in IE8, doing the basic <a > rollover using javascript does not work, yet alone show an image unless you put it in the anchor(). Maybe not the case for you but it certainly was for me.

It's also good practice at getting used to coding in PHP to use the functions and arrays, it has helped me immensely.[/quote]

anchor() is just an alias that writes an <a> tag, there's no voodoo involved that makes javascript work.

As for your second point, I couldn't disagree more... It's irresponsible to suggest to inexperienced developers that it's "good practice" to not bother learning the language they're ultimately developing in.
#10

[eluser]elaniobro[/eluser]
Well, the achor() thing was happening for me in IE8, but like I stated above it may have been something else, but this seemed to solve my issue.

As for "good practice" I think you interpreted it out of context. I myself am rather new to php and more so to codeignighter. I simply meant it's good practice in terms of helping you get familiar with how to write php functions and arrays, getting used to the syntax which in turn can help you debug more easily. Basically what you said:

Quote:...to not bother learning the language they’re ultimately developing in.


I agree, and was simply saying using img() and achor() will help you "practice" writing the code.

Smile




Theme © iAndrew 2016 - Forum software by © MyBB