<SOLVED> Modification to the submit script - is it possible...

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
User avatar
jwbassman
Forum Members
Forum Members
Posts: 22
Joined: Sat May 17, 2008 9:27 am
Location: Southport, England, UK

<SOLVED> Modification to the submit script - is it possible...

Post by jwbassman »

Hi guys

First things first - I'm running the latest version of CMSMS 1.2.5 - with PHP5 - and MySql v5

I don't know if this is possible or even desirable but can the submit button on the pages in the admin area also run the script that clears the cache when you go in the global setting and use the clear cache button then...

Reason for asking is my hosting is Servage (clustered) and on reading another post http://forum.cmsmadesimple.org/index.php/topic,19348.0.html it would appear that they were having the same problem - the pages on the site don't update until the clear cache button is pressed - whch clearly makes developing and testing a bit of a pain. As the other user I've tried turning off the PHP Acceleration etc but everything points to a server hosting issue.

I have another identical CMSMS install set up on a friends server and have none of the issues. I'm therefore guessing it's the serevr settings/configuration/cluster that are causing the problems...

Do I have any other option other than changing my host? is it possible mod the submit script to force a clear cache at the same time? can you guys thing of an alternative work around? are there any plans to make a cluster compatible version on CMCMS?

Sorry for all the questions but I have a number of projects in the pipeline and need to try and get this resolved asap - I'm really linking the CMS and found I can do all I've needed to so far so credit where it's due - but i need to know there is anything I can do...

Cheers

John
Last edited by jwbassman on Mon Jun 02, 2008 8:08 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Modification to the submit script - is it possible...

Post by calguy1000 »

You can write a UDT that clears the cache (there's an api function for it, you can see the api call in admin/globalsettings.php)

and then you can add that UDT an event handler in Extensions >> Events on the contenteditpost event (I think, there should be something in there that is obvious).
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.
User avatar
jwbassman
Forum Members
Forum Members
Posts: 22
Joined: Sat May 17, 2008 9:27 am
Location: Southport, England, UK

Re: Modification to the submit script - is it possible...

Post by jwbassman »

Hi calguy1000

thanks for the response - I'm quite new to programming but I'll have a go at what you suggest... if i get stuck I'll be back :)
User avatar
jwbassman
Forum Members
Forum Members
Posts: 22
Joined: Sat May 17, 2008 9:27 am
Location: Southport, England, UK

Re: Modification to the submit script - is it possible...

Post by jwbassman »

Hey guys - not quite sure what I've actually done (see previous note re new to programming - so writing UDT etc was lost on me) but it seems that it works...

i copied the clear cache function from the siteprefs.php

{
global $gCms;
$contentops =& $gCms->GetContentOperations();
$contentops->ClearCache();
$message .= lang('cachecleared');
}

and pasted it at the bottom of the editcontent.php

Should this work? - you guys will know better than me - it appears it does but I've no idea how :)
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: Modification to the submit script - is it possible...

Post by Nullig »

A better way would be to create a UDT named "clear_cache" (without the quotes).

Contents of the UDT are:

Code: Select all

global $gCms;
$contentops =& $gCms->GetContentOperations();
$contentops->ClearCache();
Go to Admin/Extensions/Events and click on the "ContentEditPost" event.

Add the "clear_cache" UDT from the drop-down menu. The way you're doing it, it won't work if that file ever gets updated.

That should do it.

Nullig
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Modification to the submit script - is it possible...

Post by calguy1000 »

No, that won't work

the code you pasted should work in a UDT though

so go to Extensions >> User Defined Tags
create a new UDT
paste in that code.

then go to Extensions >> Events
click on the 'ChangeContentPost' event
select the UDT
and click 'add'
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.
User avatar
jwbassman
Forum Members
Forum Members
Posts: 22
Joined: Sat May 17, 2008 9:27 am
Location: Southport, England, UK

Re: <SOLVED> Modification to the submit script - is it possible...

Post by jwbassman »

Cheers guys - you were right, the way I tried it worked once but once the page was updated it just broke everything :(

Following your instructions - User Define Tag additions - perfect - works a charm... many thanks guys - means I'm not looking for a new host :)
Pierre M.

Re: <SOLVED> Modification to the submit script - is it possible...

Post by Pierre M. »

Hello,
jwbassman wrote: ...can the submit button on the pages in the admin area also run the script that clears the cache...

Reason for asking is my hosting is Servage (clustered) and...
Thank you Calguy1000 and Nullig for the working event+UDT solution.

Just thinking loudly : couldn't this be a default global setting ? It would make such "clustered" hosting work out of the box and it shoudn't hurt others because all sites are much much much more read than modified. Nostalgia of my first post as guest ;-)

Pierre
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: <SOLVED> Modification to the submit script - is it possible...

Post by calguy1000 »

the cache should be updating by itself whenever a content or page template is changed, so there should be no need on most sites to force it.
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.
erniez13
New Member
New Member
Posts: 3
Joined: Mon Feb 11, 2008 6:25 pm

Re: <SOLVED> Modification to the submit script - is it possible...

Post by erniez13 »

Just thought I'd throw in my 2 cents that I had the EXACT same problem (also hosted on Servage) - The above solution seems to work. I'd really like to know WHY this happens though ....

Ciao
Pierre M.

Re: <SOLVED> Modification to the submit script - is it possible...

Post by Pierre M. »

Hello,
erniez13 wrote: I'd really like to know WHY this happens though
This hosting provider seems to replicate sites (actualy copying caches) on several hosts and to "expire" the copies not "fast" enough. Hence if someone hits a copy it may be an obsolete one (not yet obsoleted). And it seems that when the master's cache is cleared the replicating system catches up to clear all copies. Hence when someone hits a cleared copy the page is fresh because generated on the fly.

About this non CMSms specific topic, see Apache's mod_header, mod_expire, mod_cache and things like rsync.

Pierre M.
Post Reply

Return to “CMSMS Core”