Jump to content

Function uikit.php


MateThemes
 Share

Recommended Posts

Hello everybody!

I use the Regular blog site profile as my starter template for my new website. I also use the included uikit.php with reusable functions.

But I have one question to this uikit.php. If render an ukAlert the close trigger is not working. If i hard code the alert box, everything is working fine.

Here is the code I use (it is not modified and is provided by the Regular blog site profile):

/**
 * Render a uikit alert box
 * 
 * @param string $html Text/html to display in the alert box
 * @param string $type Specify one of: success, primary, warning, danger or leave blank for none. 
 * @param string $icon Optionally specify a uikit icon name to appear in the alert box. 
 * @return string
 * 
 */
function ukAlert($html, $type = '', $icon = '') {
	$out = $type ? "<div class='uk-alert-$type uk-alert'><a class='uk-alert-close' uk-close></a><p>" : "<div data-uk-alert><a class='uk-alert-close' uk-close></a>";
	if($icon) $out .= ukIcon($icon) . ' ';
	$out .= $html . "</p></div>";
	return $out; 
}

/**
 * Render a success alert, shortcut for ukAlert('message', 'success'); 
 * 
 * @param string $html
 * @param string $icon
 * @return string
 * 
 */ 
function ukAlertSuccess($html, $icon = '') {
	return ukAlert($html, 'success', $icon); 
}

/**
 * Render a primary alert, shortcut for ukAlert('message', 'primary');
 *
 * @param string $html
 * @param string $icon
 * @return string
 *
 */ 
function ukAlertPrimary($html, $icon = '') {
	return ukAlert($html, 'primary', $icon);
}

/**
 * Render a warning alert, shortcut for ukAlert('message', 'warning');
 *
 * @param string $html
 * @param string $icon
 * @return string
 *
 */ 
function ukAlertWarning($html, $icon = '') {
	return ukAlert($html, 'warning', $icon);
}

/**
 * Render a danger alert, shortcut for ukAlert('message', 'danger');
 *
 * @param string $html
 * @param string $icon
 * @return string
 *
 */ 
function ukAlertDanger($html, $icon = '') {
	return ukAlert($html, 'danger', $icon);
}

Here is the code in the template:

<?php
			// did we find any matches?
			if(count($matches)) {
				// yes we did, render them
				echo ukAlert("Found $matches->count page(s)", "default", "check");
				echo ukDescriptionListPages($matches);
			} else {
				// we didn't find any
				echo ukAlert("Sorry, no results were found.", "danger", "warning");
			}
			?>

May someone have the answer to this!

Thanks in advance!

Link to comment
Share on other sites

I have found it! It was my mistake!!!

In this function 

function ukAlert($html, $type = '', $icon = '') {
	$out = $type ? "<div class='uk-alert-$type uk-alert'><a class='uk-alert-close' uk-close></a><p>" : "<div data-uk-alert><a class='uk-alert-close' uk-close></a>";
	if($icon) $out .= ukIcon($icon) . ' ';
	$out .= $html . "</p></div>";
	return $out; 
}

I have forgot to add uk-alert <div class='uk-alert-$type uk-alert' uk-alert>

function ukAlert($html, $type = '', $icon = '') {
	$out = $type ? "<div class='uk-alert-$type uk-alert' uk-alert><a class='uk-alert-close' uk-close></a><p>" : "<div data-uk-alert><a class='uk-alert-close' uk-close></a>";
	if($icon) $out .= ukIcon($icon) . ' ';
	$out .= $html . "</p></div>";
	return $out; 
}

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...