Problems, need help? Have a tip or advice? Post it here.
16 posts Page 2 of 2
@KK, thank you. After your explanation I went straight to use <cms:dump />, and it made itself clear. Iterations have to stay on one element, till all the k_variables are checked and reviewed.

For example:
Code: Select all
First iteration gets info on the element 'A' and realizes, that this element is level-0, element-0.
    -element 'A' is displayed first time.
Second iteration has to check if element 'A' can have children. So it has a variable folder='1'.
    -element 'A' is displayed again, because we had to get info again.
Third iteration has to check if element 'A' has no children and we are ready to move to next one.
    -element 'A' is displayed for the third time, this time is final.

So, if we stay on level 3, and we want to go to the level 1, element 'C' will be displayed 5 times, while nested_pages tag goes 2 additional times through all parents of 'C' straight to the top..
Code: Select all
<cms:nested_pages masterpage='nested.php' extended_info='1' >
   <a href="<cms:show k_nestedpage_link />"><cms:show k_nestedpage_title /></a><br />
</cms:nested_pages>

Thank you!

Another 2 questions, please.

1st - what is the proper way to autogenerate menu with nested_pages in the following scenario:
I'd like to have in this autogenerated menu normal couch 'pages' and also some 'fake' pages, which are not used as pages, but only as fillers in menu for 'jump' links (like href="#contacts")? Advanced Menu, of course, only accepts proper http:// links, as it is intended to show a page, not "serve a jump".

2nd is more of a suggestion. Talking about Advanced Menu for a nested_page. When a mark 'points to another page' is checked, the editables of the page are hid. So, to edit some values in this page first is needed to uncheck this mark.
It is basically a non-issue, coz why would someone need editables on a page that redirects|points to another page? But I found a use case: with multilanguage setup I also want to autogenerate menus in desired language. So I implemented editable which would serve me as my own page_title_{lang} to be used in manually crafted menu (as you kindly showed in tutorials). So, just for you to know that such an editable might be needed, even when hid (of course all variables are available in runtime. It's only that they are hidden in admin panel, with mark checked.)
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
@trendoman,
I'd like to have in this autogenerated menu normal couch 'pages' and also some 'fake' pages, which are not used as pages, but only as fillers in menu for 'jump' links (like href="#contacts")? Advanced Menu, of course, only accepts proper http:// links, as it is intended to show a page, not "serve a jump".
I think we can create 'pointer-pages' pointing to e.g. '#contacts' and then generate menu the usual way - cms:nested_pages should show you that the page being iterated is a pointer-page and you can generate the markup accordingly.

Do you think it would work?
@KK, I'm stuck at this
we can create 'pointer-pages' pointing to e.g. '#contacts'

I can only create a pointer without any link.
Let's suppose, I detect all pointers in runtime and assign href="#<cms:show k_nestedpage_name />", but I will have to add another layer of conditional, so if a pointer page is not empty - then show href="its link". If empty - show href="#name".
Is it what you suggested? If so, it is a doable hack..
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Afterthought: It is really nice to autogenerate menu with cms:menu. Really nice time-saver.

This will work:
Code: Select all
<cms:menu masterpage='nested.php' last_class=' ' />
<script>
$('ul.level-0').append(
    $('<li>').attr('id','item-contacts').attr('class','level-0 last').append(
        $('<a>').attr('href','#contacts').append("Contacts")
));   
</script>


However, as long as <cms:menu /> can not have a parameter, specifying to output something else, rather than k_nestedpage_title, it is needed to use full code from documentation if dealing with multilanguage setups.

So, @KK, do you think it is an option to customize menu tag even further? Like, by default display k_menu_title, and show something else upon such a request:
Code: Select all
<cms:menu custom_field="name_<cms:show my_lang />" />


Edit: Got another use-case. Let's say we generate menu and want to show a number, after k_menu_title. Something like a number of houses in a particular category.
-Our projects (3)
--Construction (5)
---House
---Skyscraper
---Factory
---House
---Building
--Repair (2)
---Building
---Building
--Rebuild (1)
---Bridge

What is your take on this? Might be easily generated with
Code: Select all
<cms:menu custom_text='<cms:show k_menu_title />(<cms:show k_immediate_children />)' />
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
I'm posting here a full hand-made solution to generate menu, including custom links for pointer-pages without http://link. This is for generating multilanguage menu with nested pages.
Code: Select all
<cms:nested_pages masterpage='ceiling_nested.php' extended_info='1' include_custom_fields='1' >
      <cms:if k_level_start >
        <cms:if k_level='0'>
           <ul class="level-0">
        <cms:else />
           <ul>
        </cms:if>
      </cms:if>
   <cms:if k_element_start >
      <cms:if k_menu_text='#'>
      <li><a href="#<cms:show k_nestedpage_name />"><cms:get "name_<cms:show my_lang />" /></a>
      <cms:else />
      <li><a href="<cms:show k_menu_link />"><cms:get "name_<cms:show my_lang />" /></a>
      </cms:if>
   </cms:if>
   <cms:if k_element_end ></li></cms:if>
   <cms:if k_level_end ></ul></cms:if>
</cms:nested_pages>


This recipy works if:
1) A nested page consists of editables with name="name_{lang}", for example name_ru, name_en, name_ge etc..
2) A menu item, which is a dummy pointer with href="#some_id", should be assigned menu text="#" in Admin Panel, Advanced Menu.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
UP :?:
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
16 posts Page 2 of 2