{NAV_SELECTOR:parent_id:selected_id:title}
Posted: Thu 5. Aug 2004, 13:38
Hi again. Gruess euch!
I added another function which replaces the tag {NAV_SELECTOR} with a <SELECT> box. It takes parent_id (under which the entries from struct shall be displayed), selected_id (this ID will be set as selected) and title (a title / description which will be displayed as first entry) as parameters.
The replacement tag looks like this:
{NAV_SELECTOR:parent_id:selected_id:title}
Here are the functions:
conf.template_default.inc.php
Sets size (how many rows) and class (for CSS style) for the SELECT tag.
content.func.inc.php
the function for replacement
front.func.inc.php
I hope some of you find this usefull!
Cheers, Plauderer
I added another function which replaces the tag {NAV_SELECTOR} with a <SELECT> box. It takes parent_id (under which the entries from struct shall be displayed), selected_id (this ID will be set as selected) and title (a title / description which will be displayed as first entry) as parameters.
The replacement tag looks like this:
{NAV_SELECTOR:parent_id:selected_id:title}
Here are the functions:
conf.template_default.inc.php
Code: Select all
// navigation selectbox
$template_default["nav_selectbox"]["size"] = 1;
$template_default["nav_selectbox"]["class"] = "selectbox";
content.func.inc.php
Code: Select all
// NAV_SELECTOR:parent_id:selected_id:title (by Ch.Kostal, 2004)
if( ! ( strpos($content["all"],'{NAV_SELECTOR')===false ) ) {
$content["all"] = str_replace('{NAV_SELECTOR}', '{NAV_SELECTOR:0:0:}', $content["all"]);
$content["all"] = preg_replace('/\{NAV_SELECTOR:(.*?):(.*?):(.*?)\}/e', 'nav_selectbox($content["struct"], "$1", "$2", "$3", $template_default["nav_selectbox"])', $content["all"]);
}
// -------------------------------------------------------------
front.func.inc.php
Code: Select all
// by Ch.Kostal, 2004 - returns SELECT form element with given structure level
function nav_selectbox ($struct, $parent_id, $selected, $title, $nav_selectbox_struct) {
$title = ($title == "") ? false : $title;
foreach ($struct as $key => $value) {
if ($struct[$key]["acat_struct"] == $parent_id && $key && !$struct[$key]["acat_hidden"]) {
$temp_struct[ $struct[$key]["acat_id"] ] = $struct[$key];
}
}
if (sizeof($temp_struct)) {
$option_list = '';
$option_list = ($title) ? '<option value="-1">' . $title . '</option>' : '';
foreach ($temp_struct as $key => $value) {
$option_list .= ' <option ';
$option_list .= ($key == $selected) ? 'selected ' : '';
$option_list .= 'value="' . $temp_struct[$key]["acat_alias"] . '">' . $temp_struct[$key]["acat_name"] . "</option>\n";
}
$selectbox .= '<select size="' . $nav_selectbox_struct["size"] . '" name="selector" class="' . $nav_selectbox_struct["class"] . '"';
$selectbox .= " onchange=\"if(this.options[this.selectedIndex].value != -1){ window.document.location.href = '/index.php?' + this.options[this.selectedIndex].value }\">\n";
$selectbox .= $option_list . "</select>";
return $selectbox;
}
else {
return '';
}
}
// -------------------------------------------------------------
Cheers, Plauderer