From 1b8e3885089b6ff60429fe0c46f2bae01fa4d33e Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Thu, 18 Jul 2013 13:03:41 +0300 Subject: [PATCH] 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 --- application/helpers/ecards_helper.php | 18 +++++++++++------- application/views/yllapito/users_show.php | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/application/helpers/ecards_helper.php b/application/helpers/ecards_helper.php index c446e88..bc295ed 100644 --- a/application/helpers/ecards_helper.php +++ b/application/helpers/ecards_helper.php @@ -3,16 +3,17 @@ /** * 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 $text Link text - * @param string $match What url to match against, use like $url - * @param string $class What class should be added if urls match + * @param string $url Your link inside the application, not for outside links + * @param string $text Link text + * @param string $baseclass What classes should be included + * @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 * * @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 = site_url($url); @@ -26,9 +27,12 @@ function lnk($url = null, $text = null, $match = null, $class = ' active') // Return correctly formatted link if ($url == $match) { - return '' . $text . ''; + return '' . $text . ''; } else { - return '' . $text . ''; + if (! empty($baseclass)) { + $baseclass = 'class="' . $baseclass . '" '; + } + return '' . $text . ''; } } diff --git a/application/views/yllapito/users_show.php b/application/views/yllapito/users_show.php index 4e8c405..8a42c76 100644 --- a/application/views/yllapito/users_show.php +++ b/application/views/yllapito/users_show.php @@ -25,7 +25,7 @@ if ($user->can_modusers == "no") { } elseif (empty($userdata) || ! is_object($userdata)) { ?>

Käyttäjää tunnisteella # ei löydetty

- +