Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Hello all,

So I've gone through the tutorial for implementing Couch into my site. There's just one last thing, and it's the one that I find to be the hardest.

I have to implement Couch into my homepage.

This is what my homepage template looks like.

Please help me.

For the top-most section...

Image

...I want to have that be like a "Featured Posts" type of thing. Is there a way that I can pick and choose what posts I want in those spots?

For example, what I'd like to be able to do is choose from a list of posts for each of the 5 spots, and once I choose the posts I want to occupy the spots, the data for them (Author, Date, Title, Image, etc.) automatically gets inserted into those defined spots.

I doubt I'd have a problem doing it if I was just listing them, but I want to be able to pick and choose what articles/posts go into that section.

Then there's these sections.

Image

I want to do a list of pages here from different folders and whatnot, but as you can see, the left side section with the girl using the iPad is aesthetically different from the rest of the entries on the right side. So how would I go about listing a page or a folder's entries while keeping the latest post in the left area and the 2nd-to-recent to the older posts in the right area?

Those are the two main questions I have. I have 1 additional question, but it doesn't need to be answered, unless it is able to be. My main, pressing, immediate questions are the ones listed above. Anyway, here goes:

1. Can I create users that do nothing but create blog entries? If so, how?

Thank you in advance, all!
Specifically for the top-most section
Hello!

I suppose you are using <cms:pages> to make those posts. If so, you will probably find this helpful.

I have implemented a similar thing here: http://novachemicalsco.com/
The images in the banner are actually the posts that have been posted on the Products page. My client wanted to be able to pick and choose which products should be displayed in the banner right when they are making publishing the post.

So here is what was done: (obviously with help of @KK Sir)
The Approach: We decided to create an option for the page view in the backend. The option was labeled "Display in Banner" and had two choices "Yes or No". With No selected as default. (this was done on the product.php page)

The Editable Region: (on the product.php page)
Code: Select all
<cms:editable name="my_categories" label="Display in Banner?" desc="Select applicable" opt_values='No=0 | Yes=1' opt_selected='0' type='radio' />


Calling the Editable Region: (on the index.php page)
Code: Select all
<cms:pages masterpage='product.php' >
     <cms:if my_categories = '1' >
          <!--Your code for displaying the banner-->
     </cms:if>
</cms:pages>


Just to handle an accidental error: (selecting more than 5 posts)
Now if in case you happen to select, by chance, more than 5 posts then the structure will be disturbed. So to avoid that all you will have to:
Code: Select all
<cms:pages masterpage='product.php' >
     <cms:if k_count le '5'>
          <cms:if my_categories = '1' >
               <!--Your code for displaying the banner-->
          </cms:if>
     </cms:if>
</cms:pages>

The k_count will not allow more than 5 posts to be displayed at a given time.

Hope this helps for the first part.

As far as the second part is concerned, I was not quite able to understand it. If you find the above post helpful and use-able, please feel free to elaborate the second part as well.

Regards,
GenXCoders
Image
where innovation meets technology
@genxcoders ,

This worked really, really well! Thanks!

Just one problem.

I have a line of code that looks like this:
Code: Select all
<a data-slide-index="0" href="#">

...and this corresponds to that main slider.

Where it says "0" in the above code should read:
Code: Select all
<a data-slide-index="0" href="#">

Code: Select all
<a data-slide-index="1" href="#">

Code: Select all
<a data-slide-index="2" href="#">

Code: Select all
<a data-slide-index="3" href="#">

Code: Select all
<a data-slide-index="4" href="#">

...for all 5 of the entries in the slider. Otherwise, the slider breaks.

I know of the "repeat" parameter in Couch, but that just outputs the string "01234" into the data-slide-index property, which doesn't much help me.

Do you know of a way where I can get a separate, unique number in each space every time?

Thanks again for the above solution!
Maybe check available preexisting counters with <cms:dump /> ?

If k_count is available, it may look like:
Code: Select all
<a data-slide-index="<cms:show k_count />" href="#">
@jsonicx9,

I'd like to suggest a small modification to @genxcoders's following code -

Calling the Editable Region: (on the index.php page)
Code: Select all
<cms:pages masterpage='product.php' >
     <cms:if my_categories = '1' >
          <!--Your code for displaying the banner-->
     </cms:if>
</cms:pages>

If the number of pages happens to be large, the code above would be inefficient as it would fetch all the pages and then show only a few of them.

If we were to make the code as follows, the cms:pages tag will fetch only those pages that have a value of '1' in the radio-button -
Code: Select all
<cms:pages masterpage='product.php' custom_field="my_categories=='1'" >
    <!--Your code for displaying the banner-->
</cms:pages>

The code above will also solve your other problem. Change it to follows and now (as @trendoman suggested) the k_count variable would start from '0' and increment for each banner page -
Code: Select all
<cms:pages masterpage='product.php' custom_field="my_categories=='1'" startcount='0'>
    <!--Your code for displaying the banner-->
    <a data-slide-index="<cms:show k_count />" href="#">
</cms:pages>

Hope it helps.
Adding to my last post -
To limit the number of pages being fetched to a particular figure (say, 5), you can use the 'limit' parameter e.g. as follows
<cms:pages masterpage='product.php' custom_field="my_categories=='1'" startcount='0' limit='5'>
@trendoman, @genxcoders, @KK:

The lines of code worked just as needed. Thank you all.

@KK, do you know how I might go about Couch-ifying the 2nd part of my homepage? Right here?:

Image

(And, again, is there a way to create users who can only make blog posts w/o having any other privileges?)
how I might go about Couch-ifying the 2nd part of my homepage? Right here?:

If I understood the problem correctly, suppose there are blog-posts 1,2,3,4,5,6,7,8,.., you wish to show '1' on the left side and 2,3,4,5,6 on the right side. Right?

If so that can be easily done by using <cms:pages> twice -
1. once for the left-side to show only the single latest post
Code: Select all
<cms:pages masterpage='blog.php' limit='1'>
   ... will fetch the latest published post ..
</cms:pages>

2. second for the right-side to show five of the latest posts skipping the first already shown in left-side above -
Code: Select all
<cms:pages masterpage='blog.php' limit='5' offset='1'>
   ... will skip the top latest post and fetch next five after that ..
</cms:pages>


With regards to your last question -
is there a way to create users who can only make blog posts w/o having any other privileges?)
We cannot enforce this through the admin-panel. However, as an alternative we can create a section on the front-end for such users that allows only working with blog posts (it is advanced functionality and is covered in 'Advance tutorial' section here - viewtopic.php?f=5&t=8981).

Hope it helps.
8 posts Page 1 of 1