Welcome Guest, Not a member yet? Register   Sign In
Modifying html helper so lis can be anchor links
#1

[eluser]xtremer360[/eluser]
I'm attempting to turn an unordered list's lis into anchor links that have a special class, id, and href for each of them.

This is what I have so far:

Code:
<?php
$list = array(
    'Login',
    'Forgot Password'
);
$attributes = array(
'class' => 'uibutton-group'
);
echo ul($list, $attributes);
?>

Rendered should look like this:
Code:
<ul class="uibutton-group">
    <li><a class="uibutton normal" href="#"  id="but_login">Login</a></li>
    <li><a class="uibutton  normal" href="#" id="forgetpass">forpassword</a></li>
</ul>

#2

[eluser]CroNiX[/eluser]
Why not just use the anchor() function from the URL Helper to create the links?
Code:
$list = array(
  anchor('#', 'Login', 'class="uibutton normal" id="but_login"'),
  anchor('#', 'Forgot Password', 'class="uibutton normal" id="forgetpass"')
);

$attributes = array(
  'class' => 'uibutton-group'
);

echo ul($list, $attributes);
Produces:
Code:
<ul class="uibutton-group">
  <li><a href="http://yoursite.com/#" class="uibutton normal" id="but_login">Login</a></li>
  <li><a href="http://yoursite.com/#" class="uibutton normal" id="forgetpass">Forgot Password</a></li>
</ul>
#3

[eluser]InsiteFX[/eluser]
I hope you are creating a MY_html_helper and not modifing the html_helper.

And like CroNiX said above would be the best way of doing it.

Why reinvent when it has already been done?
#4

[eluser]xtremer360[/eluser]
Thank you CroNIX!




Theme © iAndrew 2016 - Forum software by © MyBB