UDTs are being silly

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
Cobby
Forum Members
Forum Members
Posts: 23
Joined: Sun Jun 17, 2007 5:15 am

UDTs are being silly

Post by Cobby »

Hi all,

Here is my problem.

If I have a tag called {page} and its contents is:

Code: Select all

$p = "1";
$page[$p] = "This is page ".$p;
$p++;
echo $page[1];
echo $page[2];
It will output:
This is page 1This is page 2

But if I put $p into a separate tag, so I hade
{p}

Code: Select all

$p = "1";
and

{page}

Code: Select all

$page[$p] = "This is page ".$p;
$p++;
echo $page[1];
echo $page[2];
If that happens it will only output:
This is page 1

I am entering {p}{page} into the page, so that is correct.

Why does it only output 1 page when I set $p in its own tag?

Does tags not recognize the value of variable from another tag?

Cheers,
Cobby
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: UDTs are being silly

Post by calguy1000 »

it's not being silly, it's a matter of scope.  if you want to access variables from one UDT in another, you will need to make that variable global in scope.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Cobby
Forum Members
Forum Members
Posts: 23
Joined: Sun Jun 17, 2007 5:15 am

Re: UDTs are being silly

Post by Cobby »

Thanks for that. Much appreciated :)
Post Reply

Return to “CMSMS Core”