Page 1 of 2
Problem with caching pages
Posted: Thu Jun 01, 2006 7:57 pm
by streever
Hi all,
I have a simple CMS site with a page that uses PHP to propogate from a database.
It is here:
http://boc.355warrenstreet.com/
If you click on Outdoor Locations--then one of the two maps--then a NUMBER on the map, then click on Outdoor Locations AGAIN, then on the map AGAIN, and now pick a new number.
You will still see the previous one you picked before.
I disabled "page cached" but that didn't help. Any ideas?
Thanks so much!
Re: Problem with caching pages
Posted: Fri Jun 02, 2006 12:12 am
by Ted
How did you integrate your code into CMSMS? Is it using a user defined tag that is reading from $_GET?
Re: Problem with caching pages
Posted: Fri Jun 02, 2006 8:05 pm
by streever
no, it's just put inside a literal tag, inside php right in the page!
that is where the "get" command is.
should it be in a user-defined tag? I don't understand that system well. I tried to paste my PHP and it gave me errors.
Can you give me a "sample" of how a get php command would look inside a user-defined tag?
Thank you so much, I really appreciate the help, as always.
Re: Problem with caching pages
Posted: Fri Jun 02, 2006 10:32 pm
by FinnK
Although I am not a programmer I think this is done by putting ordinary php-code into a user defined tag - without - at the end.
Then you call the user defined tag as usual: {tagname}
Re: Problem with caching pages
Posted: Sat Jun 03, 2006 12:08 am
by Ted
Exactly. A user defined tag is one function's worth of code. If you're just using $_GET, then you can pretty much just cut and paste it in. User defined tags output do not get any kind of caching, and it should solve your issue.
Re: Problem with caching pages
Posted: Mon Jun 05, 2006 1:48 pm
by streever
hey,
it's still not working, but now, all the user-defined tags ARE correct. thank you for helping with that...
the problem is, that it's not getting the variable out of the address bar. So here is the address, for instance:
http://boc.355warrenstreet.com/index.ph ... ocation=96
now, if I go there, that selectLocation should be passed to the page, but it isn't, as long as it's in a user-defined tag.
If it's in the code, as {php}, then it IS passed, and cached on the page.
Any ideas at all? I put all of my PHP on the page into user-defined tags (just "echos") but it isn't grabbing the variable. No errors--just not grabbing the variables.
Thanks again for any help at all--
David
Re: Problem with caching pages
Posted: Tue Jun 06, 2006 3:40 pm
by streever
Hey all,
Well, I tried removing the "get" from the user-defined tag, and putting it back into "literal", but even still it doesn't work--do you think I need to put EVERYTHING into it's own user-defined tags? Here is what I mean:
This is my current "user defined tag" for all of the top copy. The variable is not being inserted into the "echo"s throughout the rest of the page. Should EACH LINE or "function" of this code be in it's own user-defined tag?
Thanks--
$dbhost = 'bocjoomla.355warrenstreet.com';
$dbuser = "*********';
$dbpass = '********';
extract($_GET);
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
('Error connecting to mysql');
$dbname = 'bocjoomla';
mysql_select_db($dbname);
$qResult = mysql_query ("SELECT * FROM barrett_signs where locationnum = $selectLocation");
$row = mysql_fetch_array($qResult);
$rLocation .=$row['locationnum'];
$rCity .=$row['city'];
$rImg .=$row['img'];
$rMap .=$row['map'];
$rDma .=$row['dma'];
$rRoute_highway .=$row['route_highway'];
$rRoute_exit .=$row['route_exit'];
$rSize .=$row['size'];
$rFacing .=$row['facing'];
$rDec .=$row['dec'];
$rSummary .=$row['summary'];
Re: Problem with caching pages
Posted: Wed Jun 07, 2006 2:31 pm
by streever
May I top this? I'm just worried it'll fall off the radar & it's such a simple thing that I think the solution is right on the tip of someone's tongue!
Re: Problem with caching pages
Posted: Wed Jun 07, 2006 3:10 pm
by tsw
The variable is not being inserted into the "echo"s throughout the rest of the page. Should EACH LINE or "function" of this code be in it's own user-defined tag?
Not sure if I understand correctly but it seems that you are first calling this usertag and after its execution using those variables? (you can stop reading here If I didnt understand correctly
if that is what you are doing it would be variable scope broblem. those variables are only "alive" inside that usertag.
you can still export those variables to smarty if you want.
Code: Select all
global $gCms;
$smarty = &$gCms->smarty;
$test = "foobar";
$smarty->assign('tester', $test);
then if you call that usertag from a page (lets call it smarty_test) {smarty_test}. AFTER that code has been run you can use that variable with {$tester} anywhere on your page.
Re: Problem with caching pages
Posted: Wed Jun 07, 2006 3:34 pm
by streever
yes, exactly!
I am not sure that I understand completely what you mean either--let me try to re-phrase it.
Essentially I have a page that is created by having a variable in the address bar (selectLocation=some number).
If that number is 42, then the mySQL database spits out the row of information, which is displayed via Echo statements.
EVERYTHING is in user tags.
Are you saying that I use a "smarty tag" to "grab" that variable, that is in the address bar?
Will that work?
Thanks so much
Re: Problem with caching pages
Posted: Wed Jun 07, 2006 3:57 pm
by streever
Thanks for the help--I looked at this and this is what I've figured out so far.
Basically, you are saying, that the code in the user-defined tag STAYS there. The VAriable, that is.
So, in my "get" function (which is the function that: connects to the database, retrieves the mySQL info, then assigns it to variables for echoing later) I now have added the first three lines of code that follow:
global $gCms;
$smarty = &$gCms->smarty;
$smarty->assign('', $rLocation);
Now, this is assigning $rLocation (which is equal to a row in the database, defined by the variable that is grabbed from the address bar) to smarty, right? so that it can be used in other user-defined tags?
The user-defined tag that uses $rLocation is just: echo $rLocation.
Nothing is displaying on the page, so I assume I'm doing something wrong.
What follows is the entire contents of the "get" user-defined tag.
global $gCms;
$smarty = &$gCms->smarty;
$smarty->assign('', $rLocation);
$dbhost = 'bocjoomla.355warrenstreet.com';
$dbuser = 'bocjoomla';
$dbpass = 'tempest1';
extract($_GET);
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
('Error connecting to mysql');
$dbname = 'bocjoomla';
mysql_select_db($dbname);
$qResult = mysql_query ("SELECT * FROM barrett_signs where locationnum = $selectLocation");
$row = mysql_fetch_array($qResult);
$rLocation .=$row['locationnum'];
$rCity .=$row['city'];
$rImg .=$row['img'];
$rMap .=$row['map'];
$rDma .=$row['dma'];
$rRoute_highway .=$row['route_highway'];
$rRoute_exit .=$row['route_exit'];
$rSize .=$row['size'];
$rFacing .=$row['facing'];
$rDec .=$row['dec'];
$rSummary .=$row['summary'];
Re: Problem with caching pages
Posted: Wed Jun 07, 2006 4:26 pm
by tsw
try this
Code: Select all
$dbhost = 'bocjoomla.355warrenstreet.com';
$dbuser = "*********';
$dbpass = '********';
extract($_GET);
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
('Error connecting to mysql');
$dbname = 'bocjoomla';
mysql_select_db($dbname);
$qResult = mysql_query ("SELECT * FROM barrett_signs where locationnum = $selectLocation");
$row = mysql_fetch_array($qResult);
$rLocation .=$row['locationnum'];
$rCity .=$row['city'];
$rImg .=$row['img'];
$rMap .=$row['map'];
$rDma .=$row['dma'];
$rRoute_highway .=$row['route_highway'];
$rRoute_exit .=$row['route_exit'];
$rSize .=$row['size'];
$rFacing .=$row['facing'];
$rDec .=$row['dec'];
$rSummary .=$row['summary'];
global $gCms;
$smarty = &$gCms->smarty;
$smarty->assign('onerow', $row);
then in your page first call that user tag
{your_user_tag_name}
after that you can use
Code: Select all
<p>here is my data: {$onerow['locationnum']}</p>
in your page source
(if that array aproach doesnt work you can always assign those variables into seperate smarty vars)
$smarty->assign('rLocation', $rLocation); and then in your page use
Code: Select all
<p>here is my data: {$rLocation}</p>
hope this helps
Re: Problem with caching pages
Posted: Wed Jun 07, 2006 4:47 pm
by streever
that is looking great--my one question now--what is that user defined tag to contain?
so I have to make a user defined tag called "onerow" or whatever is within the '' (i.e.--here:$smarty->assign('onerow', $row);) but what should that user tag contain itself?
Thank you so much!
Re: Problem with caching pages
Posted: Fri Jun 09, 2006 1:30 pm
by streever
you still around? drop me a line!
Re: Problem with caching pages
Posted: Fri Jun 09, 2006 7:40 pm
by tsw
tsw wrote:
try this
this goes in the user tag named "your_user_tag_name":
Code: Select all
$dbhost = 'bocjoomla.355warrenstreet.com';
$dbuser = "*********';
$dbpass = '********';
extract($_GET);
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
('Error connecting to mysql');
$dbname = 'bocjoomla';
mysql_select_db($dbname);
$qResult = mysql_query ("SELECT * FROM barrett_signs where locationnum = $selectLocation");
$row = mysql_fetch_array($qResult);
$rLocation .=$row['locationnum'];
$rCity .=$row['city'];
$rImg .=$row['img'];
$rMap .=$row['map'];
$rDma .=$row['dma'];
$rRoute_highway .=$row['route_highway'];
$rRoute_exit .=$row['route_exit'];
$rSize .=$row['size'];
$rFacing .=$row['facing'];
$rDec .=$row['dec'];
$rSummary .=$row['summary'];
global $gCms;
$smarty = &$gCms->smarty;
$smarty->assign('onerow', $row);
then in your page first call that user tag
{your_user_tag_name}
after that you can use
this line just uses that variable assigned to smarty:
Code: Select all
<p>here is my data: {$onerow['locationnum']}</p>
in your page source
(if that array aproach doesnt work you can always assign those variables into seperate smarty vars)
if above doesnt work, edit that user tag so that you have different variables for each udt variable in smarty:
$smarty->assign('rLocation', $rLocation); and then in your page use
this line just uses that variable assigned to smarty:
Code: Select all
<p>here is my data: {$rLocation}</p>
hope this helps
heh, doesnt look too nice with quotes and code and colors, hope you can understand that explanation
