We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question

Blog Section

Hi all ,

I was trying to implement a section . The below is the plan on mind .

The latest updated blog will have a template , while the old ones have a different but same template . PFA the document of screentshot for the layout .

I am able to recreate the layout in html , but how do i make the blog template look different for the latest one ?

for eg : https://www.uber.com/en-IN/blog/

Thanks in advance

Titus Saju

Titus Saju 0 points

  • 1 year ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can switch inside the template:

<perch:if exists="perch_item_first">
    ... this is the first item ...
<perch:else />
    ... these are the other items ... 
</perch:if>

Thanks a lot !

Hi ,

Im not sure if i can raise a query thats related to the above here , but posting it anyways .

PFA the template of my code as below

<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
</div>

when i use the function called perch_blog_recent_posts(15); i need it to output the result in such a manner that the first three comes in a row , then net three in another row etc.

Is this possible with perch ?

Duncan Revell

Duncan Revell 78 points
Registered Developer

In your template that is used by perch_blog_recent_posts(), you can use perch:every, as per:

https://docs.grabaperch.com/templates/conditionals/every/

but as you can see , the row class has to be repeated at a count of every 3 columns . Since it is a parent element , how do i do it >?

<perch:if exists="perch_item_first">
   <div class="row" style="margin-bottom:10%">
      <div class="col-md-8"><img src="<perch:blog id="image" type="image"/>" style="width:100%;
         margin-top: 1rem;box-shadow: 2px 3px 10px 0.5px rgba(0,0,0,0.1);"/>
      </div>
      <div class="col-md-4 col-xs-12 col-sm-12 padding paddv-100 responsive-blg-padding">
         <h3 class="blog-header-main">Latest Update</h3>
         <h3 class="blog-header">
            <perch:blog id="postTitle" />
         </h3>
         <h3 class="text-left" style="margin-top:3rem">Read More &nbsp; <i class="fa fa-arrow-right" style="color:orangered" aria-hidden="true"></i></h3>
         <h3 style="font-size:1rem;font-weight:300;opacity: 0.5;margin-top:2rem">
            By 
            <perch:blog id="authorGivenName" type="hidden" />
         </h3>
      </div>
   </div>
   <perch:else />
   <div class="col-md-4">
      <div class="inner-content">
         <img src="<perch:blog id="image" type="image"/>" style="width:100%">
         <h3 style="padding:5% 5%;font-size:0.8rem;font-weight: 400;color:orangered">Digital Marketing</h3>
         <h3 style="padding:0% 5%;font-size:1.5rem;font-weight:100;line-height:1.9rem">
            <perch:blog id="postTitle" />
         </h3>
         <h3 class="text-left" style="padding:5%;font-size:0.8rem">Read More &nbsp; <i class="fa fa-arrow-right" style="color:orangered" aria-hidden="true"></i></h3>
         <h3 style="font-size:0.8rem;font-weight:300;opacity: 0.5;padding:0% 5%">
            By 
            <perch:blog id="authorGivenName" type="hidden" />
         </h3>
      </div>
   </div>
</perch:if>

The above is my template code . How do i make it in such a way that every 4th element needs to be inside a new row ?

Duncan Revell

Duncan Revell 78 points
Registered Developer

Somewhere towards the end of your element code, insert <perch:every count="3"></div><div class="row"></perch:every> That will finish the current row and start a new one.
You might end up with a blank row in certain situations (where the last row number is divisible by 3), but you'll have to see how that affects you.

Try it and see how it works out.

<perch:blog id="postDateTime" is there a way to change the template of this ?

Kindly ignore the above question .