#1 2018-04-26 11:37:55

Dp.hermes
Member
From: Paris - France
Registered: 2013-07-05
Posts: 46

PHP conditions in page view

Hello people!!

I'm desperately trying to add conditions in my page view to automatically display the page differently if there is or there is no media in an article.
The reason I need it, is that this website is for a community of nuns, old and not really friends with computers. So I want to make it as simple as possible for them. So if they add medias in an article, the page is in full width, if not, the page is in 2 columns.

For example :
IF there is a media type="picture" in one of my articles in the page, then I'll echo something like :

<div class="column full-width>
       <ion:page>
       <ion:articles type="">
       <ion:article>
       <ion:content/>
       </ion:article>
       </ion:articles>
       </ion:page>
</div>

IF there is NO media in ANY of my articles, then I'll echo :

<div class="column one-third">
       <ion:page>
       <ion:articles type="">
       <ion:article>
       <ion:medias type="picture">
       <ion:media>
       <img src="<ion:media:src/>">
       </ion:media>
       </ion:medias>
       </ion:article>
       </ion:articles>
       </ion:page>
</div>
<div class="column two-third">
       <ion:page>
       <ion:articles type="">
       <ion:article>
       <ion:content/>
       </ion:article>
       </ion:articles>
       </ion:page>
</div>

I tried a LOT of different expressions with if and else, in two different expressions or in one... But nothing seems to work...
The closest I got is this code, (even if it doesn't work) and moreover this coding looks pretty disgusting :

<ion:page>
       <ion:articles type="">
       <ion:article>
       <?php if('<ion:medias:media:src type="picture" limit="1" />' != ''): ?>
       <div class="column one-fourth column_column" style="min-height:100%;background-color: #E2E2E2;">
               <ion:medias type="picture">
               <ion:media>
               <img width="100%" style="margin-bottom:-7px!important;padding-bottom:0px!important;" src="<ion:media:src/>"/>
               </ion:media>
               </ion:medias>
         </div>

         <div class="column three-fourth column_column">
              <div class="section mcb-section" style="padding-top:80px; padding-bottom:20px; background:#fff;">
                   <div class="section_wrapper mcb-section-inner">
                         <div class="wrap mcb-wrap one  valign-top clearfix">
                              <div class="mcb-wrap-inner">
                                   <div class="column mcb-column one column_column">
                                         <div class="column_attr clearfix align_center" style="padding:0 10%;">
                                              <h2><ion:title/></h2>
                                         </div>
                                   </div>
                                   <div class="column mcb-column one column_placeholder">
                                         <div class="placeholder">
                                              <ion:content/>
                                          </div>
                                   </div>
                               </div>
                          </div>
                    </div>
              </div>
       </div>
       <?php endif; ?>
       <?php if('<ion:medias:media:src type="picture" limit="1" />' == '0'): ?>
       <div class="section mcb-section" style="padding-top:80px; padding-bottom:20px; background:#fff;">
            <div class="section_wrapper mcb-section-inner">
                  <div class="wrap mcb-wrap one  valign-top clearfix">
                         <div class="mcb-wrap-inner">
                                <div class="column mcb-column one column_column">
                                      <div class="column_attr clearfix align_center" style="padding:0 10%;">
                                            <h2><ion:title/></h2>
                                       </div>
                                 </div>
                                 <div class="column mcb-column one column_placeholder">
                                       <div class="placeholder">
                                              <ion:content/>
                                        </div>
                                  </div>
                           </div>
                   </div>
              </div>
         </div>
         <?php endif; ?>
</ion:article>
</ion:articles>
</ion:page>

I'm struggling and panicking in here!!! Ha ha.
So if someone has an idea of how to achieve it, I'm all ears.

Thanks a lot in advance.

Damien

Offline

#2 2018-04-27 23:20:08

adaliszk
Ionize Friend
From: Germany
Registered: 2010-09-20
Posts: 397
Website

Re: PHP conditions in page view

Soo you want different layout automatically when you have a media or not. I think you can do that by combining the

<ion:if>

and the

<ion:partal>

tags.

I don't remember exactly now, how the actual implementation was, but you might only need a hint wink


Webdeveloper, Programmer, Application developer, Ionize friend
@adaliszk

Offline

#3 2018-04-30 13:02:46

Dp.hermes
Member
From: Paris - France
Registered: 2013-07-05
Posts: 46

Re: PHP conditions in page view

Thanks for the reply.
Hum... I tried to implement it but didn't get to make it work. And I didn't find any documentation about that?
Does someone has an idea how to use those tags <ion:if> and <ion:partal>?

Last edited by Dp.hermes (2018-04-30 13:03:35)

Offline

#4 2018-05-04 22:22:17

adaliszk
Ionize Friend
From: Germany
Registered: 2010-09-20
Posts: 397
Website

Re: PHP conditions in page view

For ion partial: http://doc.ionizecms.com/en/tags-reference/special-tags

The if has been changed or moved, now you can assert by the given context like:

<ion:uri:entity is="page">
 This is a page
</ion:uri:entity>
<ion:else>
 This is something else
</ion:else>

Webdeveloper, Programmer, Application developer, Ionize friend
@adaliszk

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations