Author Topic: page_description in menu  (Read 80864 times)

Offline johnbroeckaert

  • Posts: 198
  • Gender: Male
page_description in menu
« on: August 28, 2019, 06:21:43 PM »
Hello,

I use a seperate showmenu2 for the external links on a site and want to display not only the menu but also the page description.
 This is the menu that i use
Code: [Select]
show_menu2(
$aMenu          = 2,
$aStart         = SM2_ROOT,
$aMaxLevel      = SM2_ALL,
$aOptions       = SM2_ALL,
$aItemOpen      = '<li><a href="[url]">[menu_title]<span>[page_description]</span></a>',
$aItemClose     = '</li>',
$aMenuOpen      = '<ul class="home-sidelinks">',
$aMenuClose     = '</ul>',
$aTopItemOpen   = false,
$aTopMenuOpen   = false
);
?>
It is only displaying the word page_desciption. what am i doing wrong?

thank you!
It is a happy talent to know how to play!

Offline Gast

  • Posts: 5920
Re: page_description in menu
« Reply #1 on: August 28, 2019, 07:18:41 PM »
very easy with a look into the readme  ;-)

[description] is the right word

Offline johnbroeckaert

  • Posts: 198
  • Gender: Male
Re: page_description in menu
« Reply #2 on: August 28, 2019, 08:50:35 PM »
Thanks Uwe!

I looked it up on: https://help.WebsiteBaker.org/en/developerguide/variables-and-constants.php
and found this:

Code: [Select]
PAGE_DESCRIPTION page description of actual page
Where is the readme you are talking about?

Thanks again
John
It is a happy talent to know how to play!

Offline johnbroeckaert

  • Posts: 198
  • Gender: Male
Re: page_description in menu
« Reply #3 on: August 28, 2019, 09:00:27 PM »
euh.....
I was a bit to soon with the thank you  :-D
tryed [description] but then it says: [description=UNKNOWN]

I tryed a code section with
Code: [Select]
<?php echo page_description?> and it gave the right tekst :-P
Still don t know how to incorperate it in showmenu

It is a happy talent to know how to play!

Offline CodeALot

  • Posts: 451
  • Gender: Male
Re: page_description in menu
« Reply #4 on: August 28, 2019, 09:30:04 PM »
This is how to do it:
Code: [Select]
show_menu2(
$aMenu          = 2,
$aStart         = SM2_ROOT,
$aMaxLevel      = SM2_ALL,
$aOptions       = SM2_ALLINFO|SM2_ALL,
$aItemOpen      = '<li><a href="[url]">[menu_title]<span> - [description]</span></a>',
$aItemClose     = '</li>',
$aMenuOpen      = '<ul class="home-sidelinks">',
$aMenuClose     = '</ul>',
$aTopItemOpen   = false,
$aTopMenuOpen   = false
);


Note the SM2_ALLINFO and [description]
Without SM2_ALLINFO the constant [description ] will NOT be shown!
« Last Edit: August 28, 2019, 09:42:44 PM by CodeALot »

Offline johnbroeckaert

  • Posts: 198
  • Gender: Male
Re: page_description in menu
« Reply #5 on: August 28, 2019, 09:54:53 PM »
@CodeALot

thank you very much!

functions perfectly (Y)
It is a happy talent to know how to play!

Offline Gast

  • Posts: 5920
Re: page_description in menu
« Reply #6 on: August 28, 2019, 10:17:18 PM »
Where is the readme you are talking about?

in modules/show_menu2/DOCS

Quote
FORMAT STRINGS
==============
The following tags may be included in the format strings for $aItemOpen and
$aMenuOpen and will be replaced with the appropriate text.

[a]             <a> tag (no class):         '<a href="[url]" target="[target]">'
[ac]            <a> tag including class:    '<a href="[url]" target="[target]" class="[class]">'
[ li ]            <li> tag including class:   '<li class="[class]">'
[ul]            <ul> tag including class:   '<ul class="[class]">'
[class]         List of classes for that page
[menu_title]    Menu title text (HTML entity escaped unless SM2_NOESCAPE flag is used)
[menu_icon_0]   URL poining to an image for display normal - status (from WB2.8.4)
[menu_icon_1]   URL poining to an image for display active/hover - status (from WB2.8.4)
[page_title]    Page title text (HTML entity escaped unless SM2_NOESCAPE flag is used)
[page_icon]      URL poining to an image relating to the current page (from WB2.8.4)
[tooltip]       Tooltip caption, normaly shown in title-attribute of links (ab WB2.8.4)
[url]           Page URL for the <a> tag
[target]        Page target for the <a> tag
[page_id]       Page ID of the current menu item
[parent]        Page ID of the parent menu item
[level]         Page level, the same number as is used for the "menu-N" CSS tag.
[sib]           Current menu sibling number
[sibCount]      Total number of siblings in this menu
[if]            Conditional test (see section CONDITIONAL FORMATTING)

The following tags are only available when the SM2_ALLINFO flag is used.

[description]   Page description
[keywords]      Page keywords

Quote
    SM2_ALLINFO     Load all fields from the page table of the database.
                                  This will result in quite a lot of memory being used
                                  and is not recommended, however it will make keywords,
                                  descriptions, and other fields available. This data
                                  is not loaded by default.

Only, to talk about.... it's, of course, also possible, to make a little change in show_menu2/include.php, if you dont want to load all datas for the whole menu tree, but with the risk, to lost this in the next upgrade. tell me, if you need more detailos about it

Offline johnbroeckaert

  • Posts: 198
  • Gender: Male
Re: page_description in menu
« Reply #7 on: August 29, 2019, 04:03:47 PM »
Hi Uwe,

The menu that i use to point out ONLY the external links is no bigger as 4 or 5 items. There is nothing else to do for this menu and it is only showing at the "home" page.

Quote
Only, to talk about.... it's, of course, also possible, to make a little change in show_menu2/include.php, if you dont want to load all datas for the whole menu tree, but with the risk, to lost this in the next upgrade. tell me, if you need more detailos about it

Should I do something in the include.php file or just leave it this way.

John
It is a happy talent to know how to play!

Offline Gast

  • Posts: 5920
Re: page_description in menu
« Reply #8 on: August 29, 2019, 06:17:46 PM »
Should I do something in the include.php file or just leave it this way.

hm.... not so easy to say  :wink:

without the flag "SM2_ALLINFO" the show_menu2-function load's the information from 15 data fields in table "pages" for every in this menu needed page or item, with "SM2_ALLINFO" 30 fields. at the end, we talk about some milliseconds and some bytes in the buffer for not needed informations like keywords, page_code etc.

if you forget to change it in the next upgrade, you lost the information about the page_description, if you dont use SM2_ALLINFO and i know, it's difficult to remember after two years or more, so maybe, SM2_ALLINFO is the best solution for you
i use some additional private fields in the pages table in my private projects, so i have not 30 fields to load, i've 40 or 45, for example: a subtitle für solutions like this here (screenshot from google)



it make's no sense for me, to load the whole pagetree with all the informations into the buffer to display only a couple of them in my menu. So i add the needed fields manually into the show_menu2/include.php and dont load everything from the database.

right place is here

the original code from WB 2.12.2 from modules/show_menu2/include.php Line 562 + 563
Code: [Select]
        $fields  = '`parent`,`page_id`,`menu_title`,`page_title`,`link`,`target`,';
        $fields .= '`level`,`visibility`,`viewing_groups`, `page_trail`';

for only one extra field, i add this at the end of line 562, if i have more fields, i add a new line behind 563 like


Code: [Select]
        $fields  = '`parent`,`page_id`,`menu_title`,`page_title`,`link`,`target`,';
        $fields .= '`level`,`visibility`,`viewing_groups`, `page_trail`,';
        $fields .= '`subtitle`,`page_subdescription`,`shorturl`, `custom1`';

in my special case, it's not possible to forget it in the upgrade, because, i work with a private solution and a free definable shorturl-keyword and the menu will not work without this keyword

my tip: if its not a private page, if its a customer project, take the secure solution with SM2_ALLINFO, that will work also in the future (i think)

Offline johnbroeckaert

  • Posts: 198
  • Gender: Male
Re: page_description in menu
« Reply #9 on: August 29, 2019, 06:53:13 PM »
thank you for your detailed explanation   (Y) (Y)
It is a happy talent to know how to play!

 

postern-length