Forum for discussing general topics related to Couch.
9 posts Page 1 of 1
Sorry if been asked before, I love working with and using couch and love how powerful it is, only thing that would love to know if possible is when creating a new page is to be able to choose what layout to use, for example the about page having a different design/layout to the index.php page

as a example the index.php has a 3 column layout using
Code: Select all
col-lg-4, col-lg-4 and col-lg-4
and the about page or new created pages have a 2 column layout like
Code: Select all
col-lg-6, col-lg-6


Is there anyway to do this or any links to something similar
Hi,

Using different layouts for different pages should be as easy as defining a dropdown showing all available layouts - the user can specify her choice while creating the page and your frontend code then uses the chosen value to show the right layout (e.g. by embedding the right snippet).

What I mentioned above has always been possible (and used) in Couch. The more practical problem that crops up with this approach is when the different cloned pages (of the same template) need different sets of editable regions - e.g. contact-us, about-us etc. will necessarily need different regions.

With Couch v2.2, this can now be handled through 'conditional fields' (viewtopic.php?f=5&t=11512). You may define several sets of regions and make them dependent on the dropdown mentioned above. This way, choosing a certain layout can also offer different editable regions in the backend.

Hope this helps.
Hi KK

That's great that it can be done using couchcms, thank you I'll take a look at conditional fields as are correct and will need different sets of editable regions. I'll have a go on the cmsdemo site I built and hopefully can do it
Just having a go at conditional fields and got it kind of working, I'm not sure what's happened in the backend but I have the checkboxes being repeated and the first checkbox when checked shows a dropdown that I don't have in the coding any more and the third checkbox does not do anything so need to remove the first and third checkbox, I have cleared the cache but it's still showing, below is the current code

Code: Select all
<cms:func _into='two_columns' two_column=''>
        <cms:if two_column='Two Column Layout'>
            show
        <cms:else />
            hide
        </cms:if>
    </cms:func>
   
<cms:func _into='three_columns' three_column=''>
        <cms:if three_column='Three Column Layout'>
            show
        <cms:else />
            hide
        </cms:if>
    </cms:func>
   
<cms:editable
        type='checkbox'
        name='two_column'
        label='Do you want two column layout?'
        opt_values='Two Column Layout'
        order='-1'
    />
   
<cms:editable
        type='checkbox'
        name='three_column'
        label='Do you want three column layout?'
        opt_values='Three Column Layout'
        order='1'
    />
   
<cms:editable name='two_column_layout1' type='row' not_active=two_columns order='3'>
        <cms:editable name='two_column_layout1_cardone' label='Card One (1)' type='text' required='1' class='col-md-6 mb-6' />
        <cms:editable name='two_column_layout1_cardtwo' label='Card Two (1)' type='text' required='1' class='col-md-6 mb-6' />
    </cms:editable>
   
    <cms:editable name='three_column_layout2' type='row' not_active=three_columns order='4'>
        <cms:editable name='three_column_layout2_cardone' label='Card One (2)' type='text' required='1' class='col-md-4 mb-4' />
        <cms:editable name='three_column_layout2_cardtwo' label='Card Two (2)' type='text' required='1' class='col-md-4 mb-4' />
        <cms:editable name='three_column_layout2_cardthree' label='Card Three (2)' type='text' required='1' class='col-md-4 mb-4' />
    </cms:editable>


I have also attached a screenshot of the issue

Attachments

I believe the code is correct as checked it lots of times to the conditional fields guide in the link KK gave, I removed the code altogether but it still appears in the couchcms backend, it's not updating in the backend for some reason. I have visited the page as as super admin but still not updating. I think it could be to do with caching I have in the htaccess file in the main root of the server.

I have updated the htacess file and it's all ok now
How do I get the relative layout to show on the front end, so if the admin user chooses two column layout in the couchcms admin backend then the two columns show on the front end or same if user chooses three column layout, in pages.php I have the following

Code: Select all
<cms:if k_is_page>
       <cms:if page_layout = 'two_columns'>
          <cms:embed 'two-column-layout.html'/>
       <cms:else />
          <cms:embed 'three-column-layout.html'/>
       </cms:if>
    </cms:if>


In the snippets folder, I have the following for two-column-layout,html

Code: Select all
    <!-- Page Content -->
    <div class="container">
     
     <!-- Content Row -->
      <div class="row">
         
        <div class="col-md-6 mb-6">
          <div class="card h-100">
            <div class="card-body">
              <h2 class="card-title">Card One</h2>
              <p class="card-text">
                <cms:show two_column_layout1_cardonetext/>
              </p>
            </div>
            <div class="card-footer">
              <a href="#" class="btn btn-primary">More Info</a>
            </div>
          </div>
        </div>
       
        <div class="col-md-6 mb-6">
          <div class="card h-100">
            <div class="card-body">
              <h2 class="card-title">Card Two</h2>
              <p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem magni quas ex numquam, maxime minus quam molestias corporis quod, ea minima accusamus.</p>
            </div>
            <div class="card-footer">
              <a href="#" class="btn btn-primary">More Info</a>
            </div>
          </div>
        </div>

      </div>
      <!-- /.row -->

    </div>
    <!-- /.container -->


At the moment, I choose two column layout in the backend but on the front end, it's showing the three column layout

UPDATE: I now got the relative layout showing on the front end now based on what is chosen on the admin side and love it, again amazes me how powerful couchcms is

The issue I have noticed is that the text is not saving in the editable richtext in the backend, it says success your changes have been saved in the backend but the text disappears when the page refreshed

Below is the updated code

Code: Select all
<cms:editable 
        type='checkbox'
        name='two_column'
        label='Do you want two column layout?'
        opt_values='Yes'
        order='-1'
/>
   
<cms:func _into='two_columns' two_column=''>
        <cms:if two_column='Yes'>
            show
        <cms:else />
            hide
        </cms:if>
    </cms:func>
<cms:editable name='two_column_layout1' type='row' not_active=two_columns order='3'>
        <cms:editable name='two_column_layout1_cardonetext' label='Card One Text' type='richtext' class='col-md-6 mb-6' />
        <cms:editable name='two_column_layout1_cardtwotext' label='Card Two Text' type='richtext' class='col-md-6 mb-6' />
</cms:editable>

<cms:editable
        type='checkbox'
        name='three_column'
        label='Do you want three column layout?'
        opt_values='Yes'
        order='1'
/>
   
<cms:func _into='three_columns' three_column=''>
        <cms:if three_column='Yes'>
            show
        <cms:else />
            hide
        </cms:if>
    </cms:func>
<cms:editable name='three_column_layout2' type='row' not_active=three_columns order='4'>
        <cms:editable name='three_column_layout2_cardonetext' label='Card One Text' type='richtext' class='col-md-4 mb-4' />
        <cms:editable name='three_column_layout2_cardtwotext' label='Card Two Text' type='richtext' class='col-md-4 mb-4' />
        <cms:editable name='three_column_layout2_cardthreetext' label='Card Three Text' type='richtext' class='col-md-4 mb-4' />
</cms:editable>


Code: Select all
<cms:if two_column>
          <cms:embed 'two-column-layout.html'/>
       <cms:else />
          <cms:embed 'three-column-layout.html'/>
       </cms:if>
I am really confused by the text not saving after clicking save in the backend, I have never came across the issue before. I have checked the error log in the cpanel and is no errors showing

Has anyone had this before?
Since the controlling field is a 'checkbox' (which can potentially have multiple selections), the correct syntax for the code should be this -
Code: Select all
<cms:if "<cms:is 'Yes' in=three_column />">

instead of what you are currently using (which would work for 'dropdown' or 'radio') -
Code: Select all
<cms:if three_column='Yes'>

Does this help?
Thank you so much has sorted the issue with the text saving

I can now crack on and am so happy and pleased I can now create new nested pages and have different layouts for different pages, is just amazing

Thank you again
9 posts Page 1 of 1

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 3 guests