5093 Posts in 1516 Topics by 1113 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 647 Views |
-
Auto Add new pages

6 October 2010 at 8:46am
Hello -
I am not sure if I can do this, so I thought I'd ask here.
I want the CMS to be able to add a Page automatically when other pages are added and certain conditions are met.For example:
I have pages that include data for a city and state. I have city and state pages that act as directories for these products. Is there a way that I can add a page, have the CMS check if that city and state already exists, and if it doesn't, then add pages for the city and state? That way, a default one can be made, but a user can go and edit content for that city later if they want.Thanks in advance!
-
Re: Auto Add new pages

6 October 2010 at 9:21pm
Hi,
I'd recommend overriding onAfterWrite function Page that you are adding, then that can call a function like the following to create the page if "certain conditions are met"... and make sure that the page has not already been created is one of those conditions
function makePage($pg,$URLSegment,$Title,$strContent,$bShowInMenus,$bShowInSearch,$iParentID=-1)
{
$pg->URLSegment = $URLSegment;
$pg->Title = $Title;
$pg->MenuTitle = '';
$pg->Content = $strContent;
$pg->MetaTitle = '';
$pg->MetaDescription = '';
$pg->MetaKeywords = '';
$pg->ExtraMeta = '';
$pg->ShowInMenus = $bShowInMenus;
$pg->ShowInSearch = $bShowInSearch;
$pg->HomepageForDomain = '';
$pg->ProvideComments = '';
$pg->Sort = '';
$pg->HasBrokenFile = false;
$pg->HasBrokenLink = false;
$pg->Status = '';
$pg->ReportClass = '';
$pg->CanViewType = 'Anyone';
$pg->CanEditType = 'LoggedInUsers';
$pg->ToDo = '';if ($iParentID!=-1)
$pg->ParentID = $iParentID;$pg->write();
$pg->writeToStage('Stage');
$pg->publish("Stage", "Live");return $pg->ID;
}usage...
$this->makePage(
new Page(),
$strURLSegment,
$strName,
$strContent,
true,
true,
$this->ID
); -
Re: Auto Add new pages

15 October 2010 at 6:39pm
Perfect. Thanks! I haven't added all the code yet, but this is definitely enough to get me going.
| 647 Views | ||
|
Page:
1
|
Go to Top |


