Problems, need help? Have a tip or advice? Post it here.
23 posts Page 2 of 3
@atisz, I can step in here with a posted trick for this viewtopic.php?f=8&t=10559
Code becomes as this
<cms:pages custom_field="expiry_date < <cms:date format='Y-m-d H:i:s' return='+5 days' />">
trendoman wrote: @atisz, I can step in here with a posted trick for this viewtopic.php?f=8&t=10559
Code becomes as this
<cms:pages custom_field="expiry_date < <cms:date format='Y-m-d H:i:s' return='+5 days' />">

@trendoman Cool solution, thanks!
Now I have another thing to solve. I want to display on the dashboard a warning message for expiring pages from 3 different masterpages. Something like: "Warning! There are 2 doc_x, 0 doc_y and 4 doc_z expiring in the following days. Click here for more details."
For counting the number of expiring pages I could use
Code: Select all
<cms:pages masterpage='members/page_name_x.php' custom_field="expiry_date_x < <cms:date format='Y-m-d H:i:s' return='+5 days' />" count_only='1' />
The problem is that I don't know how to combine the counting for the 3 masterpage, check if the returned value, at list for one of the three pages, is greater then 0, then display the div containing the warning mesage, else do not show the div.
I tried something with cms:if tag, but all I got was errors of miss-using the tag :(
Any idea about how to?
I think this similar sample from tutorials should help.
portfolio-site-162.png
portfolio-site-162.png (11.23 KiB) Viewed 958 times


Set same variable if count is over 0 for each of 3 templates. Then if this variable is not 0, show the warning.
trendoman wrote: I think this similar sample from tutorials should help.
portfolio-site-162.png


Set same variable if count is over 0 for each of 3 templates. Then if this variable is not 0, show the warning.

@trendoman Sorry for the late reply and thank you for the tip! I haven't used capture tag before, but it's perfect for what I need. Simple and to the point!

Attila
Lately I was very busy updating all information in the application and once everything was up to date I have realized things aren't ok, because even if I have no expiring documents the warning still shows up like "Warning! There are 0 doc_x, 0 doc_y and 0 doc_z expiring in the following days. Click here for more details."
Is there something wrong with the evaluation? What do you think?
Code: Select all
<cms:if ("<cms:pages masterpage='members/template_1.php' custom_field="expiry_date_1 < <cms:date format='Y-m-d H:i:s' return='+7 days' /> | stage != 'Finished'" count_only='1' /> > 0") >

Thanks!
atisz wrote: Lately I was very busy updating all information in the application and once everything was up to date I have realized things aren't ok, because even if I have no expiring documents the warning still shows up like "Warning! There are 0 doc_x, 0 doc_y and 0 doc_z expiring in the following days. Click here for more details."
Is there something wrong with the evaluation? What do you think?
Code: Select all
<cms:if ("<cms:pages masterpage='members/template_1.php' custom_field="expiry_date_1 < <cms:date format='Y-m-d H:i:s' return='+7 days' /> | stage != 'Finished'" count_only='1' /> > 0") >

Thanks!

Any idea? Anyone?
Thank you.
The best idea is to debug that line. First, I would simplify it by setting a new variable. Then I would see if the variable gets the correct expected value against sets of known incoming data.
This is what we usually do to solve errors..
trendoman wrote: The best idea is to debug that line. First, I would simplify it by setting a new variable. Then I would see if the variable gets the correct expected value against sets of known incoming data.
This is what we usually do to solve errors..


Thanks@trendoman! This is another late reply on the topic, as I managed to give it a try only today. My problem is solved only partly, as using the IF statement in another situation as follows:
Code: Select all
<li>
            <a href="template-name.php">MENU OPTION
                  <cms:if "<cms:pages masterpage='members/template-name.php' custom_field="page_hits=0" show_future_entries='1' count_only='1' />">'0' > <em><cms:pages masterpage='members/template-name.php' custom_field="page_hits=0" count_only='1' /></em>
              </cms:if>
            </a>
         </li>
I got returned nothing for <em>....</em> in case I have no page with page_hits=0, but if I have pages with page_hits=0, then before the <em>....</em> I got displayed the final part of the IF check: '0'> , just like the IF is ending right before it. So I tried to use !='0' , gt '0' to avoid using the greater sign what creates the confusion, but all I get are some errors: ERROR! LOGIC_OP: Invalid char "!" , ERROR! LOGIC_OP: Invalid char "g"
I even tried to use brackets to make the code more clear
Code: Select all
<cms:if ("<cms:pages masterpage='members/template-name.php' custom_field="page_hits=0" show_future_entries='1' count_only='1' />">'0')>
but all I get is another error message: ERROR! Unclosed bracket in "if".
This is killing me :( I'm making some mistakes or what's happening here, because I can't think clear anymore?!
@atisz, I'd suggest you please make things easier for yourself by breaking up the code in manageable chunks.
The key part in your code is the following statement -
Code: Select all
<cms:pages masterpage='members/template-name.php' custom_field="page_hits=0" show_future_entries='1' count_only='1' /> 

Capture its output into a variable for using later on as follows -
Code: Select all
<cms:capture into='my_count'><cms:pages masterpage='members/template-name.php' custom_field="page_hits=0" show_future_entries='1' count_only='1' /></cms:capture>

As you can see above, we simply wrapped <cms:capture> immediately around the original code.

And now the rest of the code should become easier to understand (and debug if necessary) -
Code: Select all
<li>
<a href="template-name.php">MENU OPTION
    <cms:if my_count gt '0' >     
        <em><cms:show my_count /></em>
    </cms:if>
</a>
</li>

Hope this helps.
Hope this helps.

Sure it does, @KK :) Complex statements always get messy with an acid mixture of double and single quotes.

@atisz, In that sample of yours, double quote inside cms:pages was considered as end of cms:if condition. The rest of the string was therefore correctly disrespected by CMS. It was considered as wrong syntax, which you saw in error messages.
23 posts Page 2 of 3