WebsiteBaker Community Forum

WebsiteBaker Support (2.12.x) => General Help & Support => Topic started by: henri on February 02, 2019, 09:29:24 AM

Title: Print function in template Fragstan
Post by: henri on February 02, 2019, 09:29:24 AM
In the template fragstan I want to replace the search function with a print function in addition to showmenu2.
Unfortunately, I can not do this with template response blue as an example.
I also can not find an example template where this print function is installed with showmenu2.
Does anyone know if this is possible in connection with the scrolling of the menu in the fragstan template.
Title: Re: Print function in template Fragstan
Post by: Gast on February 02, 2019, 11:30:09 AM
what you need, is a construction like this
How it works?
$sItemOpen is a single menu point inside of the menu, a page-link

$aTopMenuOpen is the ul around the complete menu

$sTopItemOpen is the begin from the list in the first level of the menu. You see here a multiple definition of $sTopItemOpen. Normalize, the menu was build from the left to the right or from the top to the bottom
$sTopItemOpen = ' (without a point inside) is the first and main definition of $sTopItemOpen, my Home-Buttom. It replace the Menutitle from my first page with the Home-Icon from Bootstrap
$sTopItemOpen .= ' (with a point inside) are the next definitions and come normalize on the right side of the Home-Button, but i move it via CSS to the right end, the same for the print-Button

this example use w3css and bootstrap for the icons, maybe, you start with the removing of the css classes or you take only, what you need from this example
For the print-link ($printlink) you need a special pre-definition, see example in fragstan-template
This menu needs at minimum one main definition of $sTopItemOpen . If you dont want the home-button, uncomment this code-line and remove the (red market) point in one of the next definition of $sTopItemOpen

<?php
$sItemOpen = '<li class="[class] w3-hover-theme w3-hide-small [if(class==menu-expand&&level==0){w3-dropdown-hover}]">[if(class==menu-expand&&level==2){<a class="w3-hover-none w3-padding-8" href="javascript:void(0)" title="[menu_title]"><div class="w3-dropdown-content w3-white w3-card-4">}][if(class==menu-expand){<a href="[url]" class=" w3-text-white w3-border-right">[menu_title]</a>}else{<a href="[url]" class="w3-padding-8 w3-text-white w3-border-right">[menu_title]</a>}]';

// home-button
$sTopItemOpen = '<li class="w3-border-right"><a href="'.WB_URL.'" class="w3-hover-none w3-hover-text-grey w3-padding-8"><i class="fa fa-home w3-text-white" aria-hidden="true"></i></a>';

// frontend search
$sTopItemOpen .= '<li class="w3-right w3-border-right"><a class="w3-padding-8 w3-text-white" href="javascript:void(0)" onclick="showSearch()" ><i class="fa fa-search w3-text-white"></i></a>';

// frontend print
$sTopItemOpen .= '<li class="w3-right w3-border-right"><a class="w3-padding-8 w3-text-white" href="'.$printlink.'" ><i class="fa fa-print w3-text-white"></i></a>';

// toogle mobile menu
$sTopItemOpen .= '<li class="w3-hide-medium w3-hide-large w3-opennav w3-right w3-border-right"><a class="w3-bar-item w3-button w3-padding-0 w3-hide-medium w3-hide-large w3-right w3-text-white" href="javascript:void(0)" onclick="showMenu()" title="Toggle Navigation Menu"><i class="fa fa-bars"></i></a>';

        echo show_menu2(
            $aMenu                 = 1,
            $aStart                 = SM2_ROOT,
            $aMaxLevel          = SM2_ALL,
            $aOptions            = SM2_ALL|SM2_PRETTY|SM2_BUFFER,
            $aItemOpen         = $sItemOpen,
            $aItemClose         = '</li>',
            $aMenuOpen        = '<ul class="w3-dropdown-content w3-theme" style="max-width:240px;">',
            $aMenuClose        = '</ul>',
            $aTopItemOpen    = $sTopItemOpen,
            $aTopMenuOpen   = '<ul class="w3-navbar w3-theme w3-card-2 w3-left-align w3-small">'
    ?>

result is a menu like this

(https://i.gyazo.com/885924f892883d6ffebe5ad61c0c7b81.png)
Title: Re: Print function in template Fragstan
Post by: Gast on February 02, 2019, 11:49:14 AM
Quote
see example in fragstan-template

sorry, see the example code in response blue template like

Code: [Select]
$breadcrumbstart = '<a href="'.WB_URL.'">Start</a> ';
$moredetails = '<h3>More Details:</h3>';

// redirect if this file is directly called in the browser
if(!defined('WB_URL')) {
        header('Location: ../index.php');
        exit(0);
}

//Print?
if ( isset($_GET['print']) AND $_GET['print'] == 1 ) {
        $print = true;
        $printlink = '';
        echo '<script type="text/javascript">
        window.print();
        </script>';
        $breadcrumbstart = WB_URL;
} else {
        $print = false;
        $ru = $_SERVER['REQUEST_URI'];
        if (strpos($ru, '?') > 0) {$printlink = $ru.'&amp;print=1';} else {$printlink = '?print=1';}
}
Title: Re: Print function in template Fragstan
Post by: Gast on February 02, 2019, 11:57:15 AM
sh....

forgot to close the show-menu-function at the end, here the complete code again


<?php  // is part of this code
        $sItemOpen = '<li class="[class] w3-hover-theme w3-hide-small [if(class==menu-expand&&level==0){w3-dropdown-hover}]">[if(class==menu-expand&&level==2){<a class="w3-hover-none w3-padding-8" href="javascript:void(0)" title="[menu_title]"><div class="w3-dropdown-content w3-white w3-card-4">}][if(class==menu-expand){<a href="[url]" class=" w3-text-white w3-border-right">[menu_title]</a>}else{<a href="[url]" class="w3-padding-8 w3-text-white w3-border-right">[menu_title]</a>}]';
        // home-button
        $sTopItemOpen = '<li class="w3-border-right"><a href="'.WB_URL.'" class="w3-hover-none w3-hover-text-grey w3-padding-8"><i class="fa fa-home w3-text-white" aria-hidden="true"></i></a>';
        // frontend search
        $sTopItemOpen .= '<li class="w3-right w3-border-right"><a class="w3-padding-8 w3-text-white" href="javascript:void(0)" onclick="showSearch()" ><i class="fa fa-search w3-text-white"></i></a>';
        // frontend print
        $sTopItemOpen .= '<li class="w3-right w3-border-right"><a class="w3-padding-8 w3-text-white" href="'.$printlink.'" ><i class="fa fa-print w3-text-white"></i></a>';
// toogle mobile menu
        $sTopItemOpen .= '<li class="w3-hide-medium w3-hide-large w3-opennav w3-right w3-border-right"><a class="w3-bar-item w3-button w3-padding-0 w3-hide-medium w3-hide-large w3-right w3-text-white" href="javascript:void(0)" onclick="showMenu()" title="Toggle Navigation Menu"><i class="fa fa-bars"></i></a>';

        echo show_menu2(
            $aMenu          = 1,
            $aStart         = SM2_ROOT,
            $aMaxLevel      = SM2_ALL,
            $aOptions       = SM2_ALL|SM2_PRETTY|SM2_BUFFER,
            $aItemOpen      = $sItemOpen,
            $aItemClose     = '</li>',
            $aMenuOpen      = '<ul class="w3-dropdown-content w3-theme" style="max-width:240px;">',
            $aMenuClose     = '</ul>',
            $aTopItemOpen   = $sTopItemOpen,
            $aTopMenuOpen   = '<ul class="w3-navbar w3-theme w3-card-2 w3-left-align w3-small">'
        );
    ?>
Title: Re: Print function in template Fragstan
Post by: henri on February 02, 2019, 02:17:11 PM
Hi jacobi22,

Thanks for the extensive explanation.
I'm going to try to get this working in the template.