0

I have a (P&T) Matrix storing related entries from a channel where the entry_date for each entry is being used as a go-live date. Each row with its related content and more displays as its own page.

I need to somehow grab this date or create a similar functionality within the matrix, to either close the row before a certain date, or be able to create display parameters that only show rows marked by this date or before.

The only sticking point right now is paging - which pages into rows where the related content is not yet live, and this shows empty images and content. I need to skip these instances entirely.

PHP is an option.

Thanks in advance for any tips, references, or advice that might solve this! Again, it's all about row-to-row paging, though I suppose a solution that worked for more than just paging would also be awesome.

Many thanks.

EDIT!

`

    {the_matrix limit="1" sort="asc" row_id="{segment_4}"}
                <h3>{title} - <strong>Page {if page}{page}{if:else}{field_row_count}{/if}</strong></h3> 
                <div class="pagNav">
                    {if prev_row}{prev_row}<a class="btnPrev btn" href="{path="the/path"}/{segment_3}/{row_id}" title="Prev">Previous</a>{/prev_row}{if:else}<a class="btnPrev btn inactive" href="#" title="Prev">Previous</a>{/if}
                {if next_row}{next_row}<a class="btnNext btn" href="{path="the/path"}/{segment_3}/{row_id}" title="Next">Next</a>{/next_row}{if:else}<a class="btnNext btn inactive" href="#" title="Next">Next</a>{/if}
                </div>
                <div class="navSearch">
                    <!-stuff->
                </div>
            </div>
            <div class="contentBar">
                <img src="{related}{field_content}{/related}" alt="{title} img" />  
            </div>
            <div class="pagFooter">
            <h3><strong>Page {if page}{page}{if:else}{field_row_count}{/if}</strong></h3>

                <div class="pagNav">

                {if prev_row}{prev_row}<a class="btnPrev btn" href="{path="the/path"}/{segment_3}/{row_id}" title="Prev">Previous</a>{/prev_row}{if:else}<a class="btnPrev btn inactive" href="#" title="Prev">Previous</a>{/if}
                {if next_row}{next_row}<a class="btnNext btn" href="{path="the/path"}/{segment_3}/{row_id}" title="Next">Next</a>{/next_row}{if:else}<a class="btnNext btn inactive" href="#" title="Next">Next</a>{/if}
                </div>

            </div>
            {/the_matrix}

`

So that's my Matrix code, abbreviated in obvious places. Hope it's helpful. I need to query this in such a way to prevent next_row and prev_row from pulling rows with related content that isn't live yet.

Thanks!

3
  • 1
    Do you have some code that we can see, what are you getting currently html wise and what should it actually be? Some more visuals might help me answer this.
    – Natetronn
    Commented Mar 6, 2013 at 19:56
  • 1
    Agree with Natetronn. I bet we can solve this for you with Stash pretty quickly/easily, in particular, but it'd help to see some template code!
    – adrienne
    Commented Mar 6, 2013 at 20:07
  • Thanks for the attention folks - and not having any luck figuring out returns for formatting on these comments.. Please stand by! Commented Mar 6, 2013 at 21:22

1 Answer 1

2

If I understand your question correctly this is a job for Stash, (or a custom plugin). Split the template into two parts - the first part simply fetches all the data and stashes into variables, then the second part can output those variables along with some conditional checks to ensure the dates are valid.

This should be enough to get you started:

{exp:channel:entries channel="whatever" dynamic="no" limit="1"}

    {!--  ============================================
    fetch and stash the dataset into individual variables
    ================================================== --}

    {exp:stash:set_list name="dataset" parse_tags="yes"}
        {matrix row_id="{segment_4}"}

            {stash:the_title}{title}{/stash:the_title}

            {!-- 
            add further current row fields here 
            in the form {stash:anything_you_like}{column_name}{/stash:anything_you_like}
            --}

            {stash:row_date}
                {related}
                    {entry_date}
                {/related}
            {/stash:row_date}

            {prev_row}
                {stash:prev_date}                   
                    {related}
                        {entry_date}
                    {/related}                  
                {/stash:prev_date}
                {stash:prev_id}{row_id}{/stash:prev_id} 
            {/prev_row}

            {next_row}
                {stash:next_date}                   
                    {related}
                        {entry_date}
                    {/related}                  
                {/stash:next_date}
                {stash:next_id}{row_id}{/stash:next_id}         
            {/next_row}

        {/matrix}
    {/exp:stash:set_list}


    {!--  ============================================
    start output
    ================================================== --}

    <ul>
        {exp:stash:get_list name="dataset" trim="yes"}

            {!--  ============================================
            row_date, prev_date and next_date will be empty
            if the related entry_date is in the future...
            The first check on row_date prevents hacking via the URL
            ================================================== --}

            {if row_date}
                <li>
                    <h3>{the_title}</h3>
                    {if prev_date}<p><a href="{prev_id}">Show prev row</a></p>{/if}
                    {if next_date}<p><a href="{next_id}">Show next row</a></p>{/if}
                </li>
            {/if}

        {/exp:stash:get_list}
    </ul>


{/exp:channel:entries}
1
  • Thanks so much for your answer! The client decided to add a bunch of parameters to this project, so the solution ended up being very different, and a lot simpler. Hopefully this will assist a developer in the future. Commented Aug 20, 2013 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.