mirror of
https://github.com/Ekokumppanit/ystavakylaecard.git
synced 2026-03-12 05:57:43 +00:00
Changes to lnk() helper to provide way to add base classes to link. Example usage in users_show -view where link now includes "button medium" classes
This commit is contained in:
@@ -3,16 +3,17 @@
|
|||||||
/**
|
/**
|
||||||
* lnk helps return anchor tag with class when current_url() is site_url($match)
|
* lnk helps return anchor tag with class when current_url() is site_url($match)
|
||||||
*
|
*
|
||||||
* @param string $url Your link inside the application, not for outside links
|
* @param string $url Your link inside the application, not for outside links
|
||||||
* @param string $text Link text
|
* @param string $text Link text
|
||||||
* @param string $match What url to match against, use like $url
|
* @param string $baseclass What classes should be included
|
||||||
* @param string $class What class should be added if urls match
|
* @param string $match What url to match against, use like $url
|
||||||
|
* @param string $class What class should be added if urls match
|
||||||
*
|
*
|
||||||
* @author Ismo Vuorinen <ismo.vuorinen@tampere.fi>
|
* @author Ismo Vuorinen <ismo.vuorinen@tampere.fi>
|
||||||
*
|
*
|
||||||
* @return string Formatted anchor tag with everything needed
|
* @return string Formatted anchor tag with everything needed
|
||||||
*/
|
*/
|
||||||
function lnk($url = null, $text = null, $match = null, $class = ' active')
|
function lnk($url = null, $text = null, $baseclass = '', $match = null, $class = ' active')
|
||||||
{
|
{
|
||||||
// $url should be "controller/action", no need to give full url
|
// $url should be "controller/action", no need to give full url
|
||||||
$url = site_url($url);
|
$url = site_url($url);
|
||||||
@@ -26,9 +27,12 @@ function lnk($url = null, $text = null, $match = null, $class = ' active')
|
|||||||
|
|
||||||
// Return correctly formatted link
|
// Return correctly formatted link
|
||||||
if ($url == $match) {
|
if ($url == $match) {
|
||||||
return '<a class="' . $class . '" href="' . $url . '">' . $text . '</a>';
|
return '<a class="' . $baseclass . $class . '" href="' . $url . '">' . $text . '</a>';
|
||||||
} else {
|
} else {
|
||||||
return '<a href="'. $url .'">' . $text . '</a>';
|
if (! empty($baseclass)) {
|
||||||
|
$baseclass = 'class="' . $baseclass . '" ';
|
||||||
|
}
|
||||||
|
return '<a ' . $baseclass . 'href="'. $url .'">' . $text . '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ if ($user->can_modusers == "no") {
|
|||||||
} elseif (empty($userdata) || ! is_object($userdata)) {
|
} elseif (empty($userdata) || ! is_object($userdata)) {
|
||||||
?>
|
?>
|
||||||
<h2>Käyttäjää tunnisteella #<?php echo $userid; ?> ei löydetty</h2>
|
<h2>Käyttäjää tunnisteella #<?php echo $userid; ?> ei löydetty</h2>
|
||||||
<?php echo lnk("yllapito/users", "Takaisin"); ?>
|
<?php echo lnk("yllapito/users", "Takaisin", 'button medium'); ?>
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user