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>