Problems, need help? Have a tip or advice? Post it here.
18 posts Page 2 of 2
Code: Select all
<cms:pages masterpage='your template title' >
was an example so you get an error.

try to replace 'your template title' wit the template your purchase_date is stored
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Tomarnst wrote:
Code: Select all
<cms:pages masterpage='your template title' >
was an example so you get an error.

try to replace 'your template title' wit the template your purchase_date is stored



I did change 'your template title' with my own page title. But still its not working.

Code: Select all
                                            <cms:pages masterpage=k_user_template page_id=k_user_id limit='5'>           
                                            <tr>
                                                <th scope="row">
                                                    <cms:php>
                                                        global $CTX;
                                                        $today = new DateTime(date($CTX->get('cur_date')));
                                                        $pday = new DateTime(date($CTX->get('start_date')));
                                                        $dayz = $pday->diff($today)->days;
                                                        $CTX->set( 'dayz', $dayz, 'global' );
                                                    </cms:php>
                                            </th>
                                                <td><cms:show fullname /></td>
                                                <td><cms:show address />, <cms:show postalcode /> <cms:show city /></td>
                                                <td><cms:show phone /></td>
                                                <td><cms:show account /></td>
                                                <td><cms:show birthday /></td>
                                                <td><cms:show varmearbeider /></td>
                                            </tr>
                                             </cms:pages>
Try placing <cms:show dayz /> (and you should see this variable inside of a cms:dump placed within the pages loop.)
Image
Hi

Is the variable start_date available ?

edit:

also cur_date variable ?
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Bartonsweb wrote: Try placing <cms:show dayz /> (and you should see this variable inside of a cms:dump placed within the pages loop.)


THANKS ALOT, now its working perfect :)
Today when trying to access Dashboard.php the site want work. Removing the

Code: Select all
<cms:php>
                                                        global $CTX;
                                                        $today = new DateTime(date($CTX->get('cur_date')));
                                                        $pday = new DateTime(date($CTX->get('start_date')));
                                                        $dayz = $pday->diff($today)->days;
                                                        $CTX->set( 'dayz', $dayz, 'global' );
                                                    </cms:php>


Then the page works again. But now the counter is gone. Anyone have any ideea why the code break my page?

I realy want this function to work again.
I'm really sorry for replying to such an old post, however a doubt appeared, and I'm really not good at PHP.

The code works great, and gives me the difference between the dates. However, regardless if it's a date in future or past, It returns a positive number.

Ex.: If calculating the difference between today (09/02) and tomorrow (10/02), the result will be "1". However, if calculating the difference between today and yesterday, the result will still be "1", instead of "-1".

How can I solve this?
AmaralSites wrote: I'm really sorry for replying to such an old post, however a doubt appeared, and I'm really not good at PHP.

The code works great, and gives me the difference between the dates. However, regardless if it's a date in future or past, It returns a positive number.

Ex.: If calculating the difference between today (09/02) and tomorrow (10/02), the result will be "1". However, if calculating the difference between today and yesterday, the result will still be "1", instead of "-1".

How can I solve this?

Compare dates in Ymd format with bare <cms:if> literally - if 20220209 (today) < 20220910 (tomorrow). If the answer is yes then the difference is positive, otherwise negative.
18 posts Page 2 of 2
cron