Forum for discussing general topics related to Couch.
10 posts Page 1 of 1
I need to only return past pages from a editable date field with the custom field parameter. ie
Code: Select all
<cms:set curr_date="<cms:date format='Y-m-d H:i:s' />" />
<cms:pages orderby='start_date' order='asc' custom_field="end_date <= curr_date">

unfortunately, this code throws an error. Is there any way to do this?

note: end_date is a text date validated editable region of my clonable page. I know I can use <cms:if less than > with a date however is there any way to get the custom_field to do this?
Lots of style and minimal fuss, if only everyday could be that easy.
Please try this -
Code: Select all
<cms:set curr_date="<cms:date format='Y-m-d H:i:s' />" />
<cms:pages orderby='start_date' order='asc' custom_field="end_date <= <cms:show curr_date />">

Does it help?
Yes, that worked.
Now I need to figure out a way to easily only view the pages that are returned either with a end_date before today or after today. I am not sure how to get this to work, eg I want to include a link to only past exhibitions on the main exhibitions page. Also, I need to know prior to rendering the pages in the -breadcrumbs- that the current page is a past exhibition so that I can add a Past Exhibitions link to the breadcrumbs. This seems like it might be too complicated so I may just take this out of the functionality if it so.

Thanks.
Lots of style and minimal fuss, if only everyday could be that easy.
Hi,

Following gives several examples of how to show pages that fall within a specified time period -
viewtopic.php?f=8&t=8316

Does any of those help you in handling your requirement?
Please let us know.

Thanks.
No, I don't think that solution will work. The publish date is completely separate from the exhibition start_date and end_date. I need to return pages that have a custom "end_date" field -which is a text field formatted for date entries- that is before or after the current date.
Lots of style and minimal fuss, if only everyday could be that easy.
OK, let us try it again -

I need to figure out a way to easily only view the pages that are returned either with a end_date before today or after today
If I understood it right, those would be two different pages - Past exhibitions (end_date before today) and Current Exhibitions (end_date after today).

If that is not correct, please explain in more details.

Else, you have already solved the first kind of page i.e. Past exhibitions (end_date before today)
Code: Select all
<cms:set curr_date="<cms:date format='Y-m-d H:i:s' />" />
<cms:pages orderby='start_date' order='asc' custom_field="end_date <= <cms:show curr_date />">

A minor change to the code above will list current exhibitions.
So where is the problem? Can you please let me know?

Also, I need to know prior to rendering the pages in the -breadcrumbs- that the current page is a past exhibition so that I can add a Past Exhibitions link to the breadcrumbs
A current page would be considered as a past exhibition if its 'end_date' would be less than the current date. It is almost the same as the code we have already used -
Code: Select all
<cms:set curr_date="<cms:date format='Y-m-d H:i:s' />" />
<cms:if end_date lt curr_date>
    .. show link to past exhibitions ..
</cms:if>
If I understood it right, those would be two different pages - Past exhibitions (end_date before today) and Current Exhibitions (end_date after today).


Ok. Yes this was my thinking that I would need two pages. Now that there are two pages, one for that displays the current exhibitions (end_date after today) and one empty clonable template for past exhibitions that lists them with this code
Code: Select all
<cms:set curr_date="<cms:date format='Y-m-d H:i:s' />" />
                                <cms:pages masterpage='exhibitions.php' orderby='start_date' order='asc' custom_field="end_date <= <cms:show curr_date />">
            <cms:set my_exhibition_image = gg_image />
            <cms:if my_exhibition_image=''><cms:set my_exhibition_image="<cms:show k_admin_link />theme/images/empty-folder.gif" /></cms:if>
            <li><a href="<cms:show k_page_link />"><div><img src="<cms:show my_exhibition_image />" /></div><div><h3><cms:show exhibition_name /></h3>
                        <b>Dates:</b> <cms:date start_date format='D jS M, Y'/> through <br/><span style="position:relative;left:60px;top: 6px;"><cms:date end_date format='D jS M, Y'/></span></div></a>
            </li>
    </cms:pages>


Unfortunately, now the problem exists that once the page is clicked with <cms:show k_page_link > it just goes to the original current exhibitions template to display it not the past exhibition template. So is there any way to force couch to display the page view of one template from an external template. For example, display the page view of a item of the current exhibitions (which holds all the fields) in the past exhibitions template (just a empty template so it can have a dedicated link). And how would this link be displayed?

A secondary but related question, is the page tag can return multiple pages using the id parameter. I need to use this functionality to return all the exhibitions related to a certain painting if there are more than one I will have something like <cms:pages masterpage="exhibitions.php" id="12, 11" > however how can I do this without hardcoding the id parameter and how will the link that calls up such a home view be created and work with pretty urls.

Hope this all makes sense, let me know if I need to clarify.
Lots of style and minimal fuss, if only everyday could be that easy.
it just goes to the original current exhibitions template to display it not the past exhibition template
So is it that you want to show a past exhibition single page in a different layout?

If so, you don't need a separate template for that. You can just use a different snippet to show the fields in the page-view of the original template e.g.
Code: Select all
<cms:if k_is_page>
    <cms:set curr_date="<cms:date format='Y-m-d H:i:s' />" />

    <cms:if end_date lt curr_date>
        <cms: embed 'past_view.html' />
    <cms:else />
        <cms: embed 'current_view.html' />
    </cms:if>
</cms:if>

The two snippets will show the page's field in whatever format you wish.

I will have something like <cms:pages masterpage="exhibitions.php" id="12, 11" > however how can I do this without hardcoding the id parameter

All the tags that fetch pages e.g. cms:pages, cms:related_pages etc. accept a parameter named 'ids_only' which can be set to '1' to make the tags return only the ids separated by commas. For example -
Code: Select all
<cms:set selected_ids="<cms:pages masterpage='exhibitions.php' ids_only='1' />" />

<cms:pages masterpage='exhibitions.php' id=selected_ids>
    <a href="<cms:show k_page_link />"><h3><cms:show k_page_title /></h3></a>
</cms:pages>

The example above doesn't do anything useful (as the first statement fetches ids of the 'exhibitions.php' pages and the second statement then uses the ids to get the full pages) but it illustrates how it is done.

You can use the first statement to get ids of pages related to whatever other entities you have and then get the full pages.

how will the link that calls up such a home view be created and work with pretty urls.
Sorry couldn't get you on this. Can you please explain it a little more?

Thanks.
Basically, if I have code similar to
Code: Select all
<cms:pages masterpage='exhibitions.php' id=selected_ids>
    <a href="<cms:show k_page_link />"><h3><cms:show k_page_title /></h3></a>
</cms:pages>


How do I code a link that will load this page? Because as soon as the page is reloaded or the link is followed I will loose all my data from selected_ids.
Lots of style and minimal fuss, if only everyday could be that easy.
I think I am lost now and can no longer follow what you are trying to do, siliconpoetry.

Please post some wireframes or screenshots detailing exactly what you are trying to achieve (try not to post solutions - just the problems).

Thanks.
10 posts Page 1 of 1
cron