Forum for discussing general topics related to Couch.
13 posts Page 1 of 2
Hi everybody so i dont know if this is possible.

i have a bottom menu on my webapp in each cloned page and i want to link each section to its proper page but in order to do so i have created a relationship to each of the individual templates then i show the page link but the problem is going into each page and creating a relationship is taking forever becuase its over 500 pages

i would be great if you guys could help me out how to identify using an if statement or something else how to get the proper link or each page without having to select it from a dropdown menu from every single page.

the pages are named the same in each different template btw

Thank you ahead of time.



Code: Select all
<cms:related_pages 'gd_page'>
   
                <a href="<cms:show k_page_link/>" class="item">
               
</cms:related_pages>
                    <div class="col">

                        <ion-icon name="information-circle-outline"></ion-icon>
            <cms:related_pages 'global'>   
                        <strong><cms:show gd_bmenu/></strong>
      </cms:related_pages>            
                    </div>

                </a>
      
<cms:related_pages 'vb_page'>         
                <a href="<cms:show k_page_link/>" class="item">
</cms:related_pages>
                    <div class="col">

                        <ion-icon name="camera"></ion-icon>
<cms:related_pages 'global'>   
                        <strong><cms:show vb_bmenu/></strong>
</cms:related_pages>
                    </div>

                </a>
      
<cms:related_pages 'bul_page''global'>
              <a href="<cms:show k_page_link/>" class="item">
</cms:related_pages>
                    <div class="col">

                        <ion-icon name="archive-outline"></ion-icon>
<cms:related_pages 'global'>
                        <strong><cms:show bul_bmenu/></strong>
</cms:related_pages>
                    </div>

            </a>

<cms:related_pages 'p_page''global'>
                <a href="<cms:show k_page_link/>" class="item active">
</cms:related_pages>
                    <div class="col">

                        <ion-icon name="pricetags"></ion-icon>
<cms:related_pages 'global'>
                        <strong><cms:show p_bmenu/></strong>
</cms:related_pages>
                    </div>

                </a>


                <a href="#" class="item">

                    <div class="col">

                        <ion-icon name="people-outline"></ion-icon>

                        <strong>Tech assistance</strong>

                    </div>

                </a>

I'm having trouble picturing your structure. Could you post a list of your templates and how exactly they relate to one another? What's being listed? Blog articles, product listings, etc?

without having to select it from a dropdown menu from every single page

That sounds like you're selecting from a 'has one' relation dropdown in the admin panel. If so, are you aware of 'advanced_gui' option? It will give you a pop up modal with a search bar instead of a dropdown for selecting a related page. You can do the same with has='many'.

Code: Select all
<cms:editable
  name='my_relation'
  type='relation'
  masterpage='my-related-template.php'
  has='one'
  advanced_gui='1'
/>

- - - - - - -

Also, to keep your code tidy, you may consider the following approach instead of wrapping around the opening of that anchor tag. I've had to wrap like that before and didn't like how it messed with my indenting (my code editor didn't like it either :lol: ).

Code: Select all
<cms:set my_related_global="<cms:related_pages 'global' ids_only='1' />" />
<cms:related_pages 'gd_page'>
    <a href="<cms:show k_page_link/>" class="item">
        <div class="col">
            <ion-icon name="information-circle-outline"></ion-icon>
            <cms:pages masterpage='my-related-template.php' id=my_related_global>   
                <strong><cms:show gd_bmenu /></strong>
            </cms:pages>
        </div>
    </a>
</cms:related_pages>
sorry im not great at explaining but ill do my best to give you a picture.

i have 4 template pages

General data
Valve body
Products
Landing page

i have a bottom menu that has four links to its related page.
they all relate to eachother and are named the same

eg.
4l60e_general data
4l60e_valve body
4l60e_products
4l60e_landing page

i want to link its correspoding partner so when you hit the link in the bottom its the correct cloned page
i hope i explained myself im really bad at it.

here is a sample of one linked already using the has one method.
https://transgo.tech/ps.php?p=35

btw im not familiar with the advance gui and not soo advanced myself if you couldnt already tell.
Do not use direct "hard" relations in links, because it is a typing nightmare as you had seen. Use indirect "soft" linking via query parameters. Shift the burden of determining which "general data" page needs to be linked from the primary product page to the secondary "general data" template itself.

Pass k_page_id of your product to the other templates in a querystring and receive that page id on those templates in order to determine which page to show, example --

Code: Select all
(Primary "Products" template page with bottom menu)
https://transgo.tech/ps.php?p=35

(Secondary "General data" template receives information about product id and fetches corresponding page)
https://transgo.tech/gds.php?show-product-id=35

Main code to decide which related page to display will be coded one time in each secondary template (gds.php, vds.php, etc..). Tags: add_querystring, gpc.

With more tweaking of the backend, you may even forgo direct relations completely and rely on page names to establish imaginary relations, this is possible since your page names go with a certain established naming convention.
Trendoman thank you so much for the reply!!!!

BUT your going to have to excuse my ignorance i am having so much trouble wrapping my head around how gpc and add_querystring works and how to implement it.
rudydjmedina wrote: Trendoman thank you so much for the reply!!!!

BUT your going to have to excuse my ignorance i am having so much trouble wrapping my head around how gpc and add_querystring works and how to implement it.


You are absolutely excused :)

Believe me, you want to find time to read about url parameters (synonym of query string) and how they are used to pass little pieces of information from source page to another target page. Unfortunately I am not aware of such a tutorial in CouchCMS knowledge base, maybe @KK would source you one. Shouldn't be difficult to google something about it.
I did some reasearch and i dont think this will help me i am simply trying to come up with an if statement that i can compare the current page name with others with the same pagename from other related templates without having to relate them using relationships

Sounds easy when i say it hahaha
There is no primary and secondary page atleast not how im think about it
I am leaning towards what @trendoman suggested -
you may even forgo direct relations completely and rely on page names to establish imaginary relations, this is possible since your page names go with a certain established naming convention.

Since you have well defined naming structure, it should be easier for every page to figure out the name of its corresponding "related" pages and use something like the following to fetch those -
Code: Select all
<cms:pages page_name=figured_out_name masterpage=the_other_template.php limit='1'>
..
</cms:pages>

If you need further help with this, please post the correct names of all the four pages belonging to 3 sets (the ones you posted above are not correct - names cannot have spaces). To reiterate, post 12 names (i.e. 3 sets of related pages) for us to figure out the underlying pattern.
Thank you guys for all your help so far.

So here it goes.

i have 5 templates.
gds.php
buls.php
lands.php
ps.php
vbs.php


sets would be
1. as68rc (gds.php)
2. as68rc (buls.php)
3. as68rc (ps.php)
4. as68rc (vbs.php)

1. 4l60e (gds.php)
2. 4l60e (buls.php)
3. 4l60e (ps.php)
4. 4l60e (vbs.php)

1. c4 (gds.php)
2. c4 (buls.php)
3. c4 (ps.php)
4. c4 (vbs.php)


Im currently creating a relationship with eachother then using the <cms:related_pages> tag to get k_page_link for the bottom menu.

my goal to hard code into each template if your a cloned gds.php named 4L60E. the 4 links at the bottom are linked to
4L60E in buls.php, 4L60E in lands.php, etc.

so that you can access its partnered page from any one your on.




This is currently the way i am doing things.
Code: Select all

<cms:editable type='relation' name='gd_page' label='General data page' masterpage='gds.php'  has='one' advanced_gui='1' />
<cms:editable type='relation' name='vb_page' label='Valve body page' masterpage='vbs.php' has='one' advanced_gui='1'/>
<cms:editable type='relation' name='bul_page' label='Bulletins data page' masterpage='buls.php' has='one' advanced_gui='1'/>
<cms:editable type='relation' name='p_page' label='Products data page' masterpage='ps.php' has='one' advanced_gui='1'/>
<cms:editable type='relation' name='global' label='Global' masterpage='global.php' has='one' scope='global' advanced_gui='1'/>



<div class=" full mt-2">

         

            <!-- App Bottom Menu -->

            <div class="appBottomMenu">

<cms:related_pages 'gd_page' >      
                <a href="<cms:show k_page_link/>" class="item active">
                    <div class="col">
                        <ion-icon name="information-circle-outline"></ion-icon>
                  <cms:pages masterpage='global.php'>   
                        <strong><cms:show gd_bmenu/></strong>
                     </cms:pages>
                    </div>
                </a>
</cms:related_pages>

<cms:related_pages 'vb_page' >      
                <a href="<cms:show k_page_link/>" class="item">
                    <div class="col">
                        <ion-icon name="camera"></ion-icon>
                  <cms:pages masterpage='global.php'>   
                        <strong><cms:show vb_bmenu/></strong>
                     </cms:pages>
                    </div>
                </a>
</cms:related_pages>      
<cms:related_pages 'bul_page' >      
                <a href="<cms:show k_page_link/>" class="item">
                    <div class="col">
                        <ion-icon name="archive-outline"></ion-icon>
                  <cms:pages masterpage='global.php'>   
                        <strong><cms:show bul_bmenu/></strong>
                     </cms:pages>
                    </div>
                </a>
</cms:related_pages>
<cms:related_pages 'p_page' >      
                <a href="<cms:show k_page_link/>" class="item">
                    <div class="col">
                        <ion-icon name="pricetags"></ion-icon>
                  <cms:pages masterpage='global.php'>   
                        <strong><cms:show p_bmenu/></strong>
                     </cms:pages>
                    </div>
                </a>
</cms:related_pages>
                <a href="#" class="item">
                    <div class="col">
                        <ion-icon name="people-outline"></ion-icon>
                        <strong>Tech assistance</strong>
                    </div>
                </a>

            </div>

            <!-- * App Bottom Menu -->

        </div>
Thanks.

Since all the four pages of a set have exactly the same name, here is what you can do to fetch them from their respective templates -
Code: Select all
<cms:set my_current_template = k_template_name scope='global' />

<cms:pages page_name=k_page_name masterpage='gds.php' limit='1'>
    <a href="<cms:show k_page_link />" class="<cms:if k_template_name eq my_current_template>item active</cms:if>">
        ..display whatever..
    </a>
</cms:pages>

<cms:pages page_name=k_page_name masterpage='buls.php' limit='1'>
    <a href="<cms:show k_page_link />" class="<cms:if k_template_name eq my_current_template>item active</cms:if>">
        ..display whatever..
    </a>
</cms:pages>

<cms:pages page_name=k_page_name masterpage='ps.php' limit='1'>
    <a href="<cms:show k_page_link />" class="<cms:if k_template_name eq my_current_template>item active</cms:if>">
        ..display whatever..
    </a>
</cms:pages>

<cms:pages page_name=k_page_name masterpage='vbs.php' limit='1'>
    <a href="<cms:show k_page_link />" class="<cms:if k_template_name eq my_current_template>item active</cms:if>">
        ..display whatever..
    </a>
</cms:pages>

No need to explicitly create any relationships.
Does this help?
13 posts Page 1 of 2