Idea - Page Generator

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm
Location: Florida West Coast

Idea - Page Generator

Post by versatility »

I use CMS for a lot of websites, and am always thinking of way to try to get more done in less time.  One of the ideas I have bouncing around for a long time is some type of page generator.

I normally end up with 10 to 50 pages in a site, and it takes quite a while to go through the Add New Content drill.  I tend to work in a non-linear fashion, so it would be ideal if I could somehow generate a bunch of pages, then go back and change templates, modify their attributes etc.

I know I do not have the skill to create a module to do this, but I could collaborate with someone else on the ideas and help with the documentation and testing if someone else is interested.

Also, if there is a simpler way to do this that I do not know about, like generating records in the db, I'd be all for it.
savagekabbage
Forum Members
Forum Members
Posts: 75
Joined: Mon Apr 23, 2007 3:51 pm
Location: Northern Virginia, United States

Re: Idea - Page Generator

Post by savagekabbage »

I was thinking of some way to do this myself.  I think some sort of outline tool would be best.  You would be able to layout your entire content hierarchy, giving each page titles while doing this, then the script would create all of the content for you. 

I'm sure we could come up with some sort of ajax-y module to do this for us.
cyberman

Re: Idea - Page Generator

Post by cyberman »

versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm
Location: Florida West Coast

Re: Idea - Page Generator

Post by versatility »

savagekabbage - you are speaking my language, that is exactly what I looking for/wanting to do

cyberman - Am designerish type gal - I can rock the mysql and plod through just enough php to get the job done.  Can you elaborate on the script a bit, what it does, where and how it would be run, how I would modfiy to fit needs?  :)
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm
Location: Florida West Coast

Re: Idea - Page Generator

Post by versatility »

I did copy the script down and am getting to know it a bit, confidence rising :)
cyberman

Re: Idea - Page Generator

Post by cyberman »

versatility wrote: Can you elaborate on the script a bit, what it does, where and how it would be run, how I would modfiy to fit needs?  :)
Put the script in CMSms root. Modify value "$content" (it's the default/inserted content), "$end" (the number of new pages) and maybe "$template_id" (it's the id of template).

Then you can run it with http://www.your-domain.com/makecontent.php  ;) ...
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm
Location: Florida West Coast

Re: Idea - Page Generator

Post by versatility »

Cyberman, I modified the script, named it makecontent.php, full permissions, and just got a blank page, no errors, no positive messages, and no content in the db.  The site is running v1.1.1

Here is the code I am using:

Code: Select all

<?php
require_once("include.php");
// Quick and dirty script
// It trunctes table content and content_props and write new contents

$template_id = 18;

$content ='
<h1>Fusce tincidunt. Sed ultrices massa vitae tellus. Curabitur molestie aliquam.</h1>
  <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque  sagittis tincidunt elit. Donec porta volutpat ante. Donec gravida quam  et diam. Aenean molestie. Suspendisse potenti. Nam nonummy sagittis  quam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices  posuere cubilia Curae; Etiam id elit vitae pede condimentum feugiat.  Integer libero mauris, convallis quis, auctor vel, aliquam eget, lorem.  Fusce vitae tellus ac justo pellentesque imperdiet. Maecenas interdum  commodo augue. Sed quis nunc vitae orci convallis suscipit. Cras dolor  massa, ornare sed, accumsan sodales, egestas non, dui. Suspendisse ut  lorem. Praesent porttitor lobortis metus. Fusce dolor nulla, egestas  vel, pulvinar vel, vulputate pretium, dui. Nulla venenatis rhoncus  purus. Donec in nisl. Fusce congue. </p>
  <img src="images/placeholder" />
  <h2>Fusce tincidunt. Sed ultrices massa vitae tellus. Curabitur molestie aliquam.</h2>
  <p>Ut elementum convallis mauris. Curabitur mattis enim sed mauris.  Curabitur felis. Nullam dictum, urna in pharetra pharetra, diam dui  facilisis nulla, at gravida arcu arcu quis nunc. Pellentesque sed nibh  non metus scelerisque aliquam. Cras ac felis. Ut hendrerit est. Aenean  laoreet sollicitudin eros. Aenean hendrerit quam nec massa. Sed eu  nunc. Duis vitae tortor faucibus neque elementum sodales. Sed hendrerit  tincidunt velit. Sed dolor metus, vulputate non, aliquam eu, viverra  id, arcu. Fusce interdum tellus sit amet lorem. Morbi eget lacus.  Curabitur in turpis. </p>
  <h3>Fusce tincidunt. Sed ultrices massa vitae tellus. Curabitur molestie aliquam.</h3>
  <p>Proin pretium suscipit mauris. Aliquam sapien justo, aliquet nec,  dignissim a, dignissim vitae, ligula. Nunc tincidunt. Donec facilisis.  Ut vitae nulla. Ut in lacus. Proin egestas justo et felis. Proin magna  quam, tincidunt vitae, rhoncus semper, aliquet vitae, justo. Duis est  ligula, tincidunt at, porta eu, egestas et, arcu. Donec mattis  convallis lectus. Ut purus justo, ultricies sollicitudin, gravida ac,  euismod in, diam. Curabitur risus. Etiam purus. Sed in eros. Donec arcu  ipsum, tincidunt sed, euismod eget, interdum ac, augue. Etiam massa  elit, sodales auctor, posuere vitae, euismod eget, dui. Aliquam  scelerisque nisi a felis. </p>
  <h4>Fusce tincidunt. Sed ultrices massa vitae tellus. Curabitur molestie aliquam.</h4>
  <ul>
    <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
    <li>In suscipit elementum nulla.</li>
    <li>In et est ac quam mollis venenatis.</li>
    <li>Fusce viverra risus non dolor.</li>
    <li>Ut et justo sagittis dolor convallis vehicula.</li>
  </ul>
  
  <ul>
    <li>Phasellus ultrices pellentesque lorem.</li>
    <li>In tristique massa bibendum mauris.</li>
    <li>Sed interdum scelerisque nunc.</li>
    <li>Mauris eu nulla ut ipsum cursus auctor.</li>
    <li>Donec mollis massa dignissim sem.</li>
  </ul>
  <h5>Sample Link List</h5>
  <ul>
    <li><a href="#">Sed non odio in nisl pretium bibendum.</a></li>
    <li><a href="#">Morbi tincidunt enim vel neque elementum dictum.</a></li>
    <li><a href="#">Morbi dictum est in erat.</a></li>
    <li><a href="#">Integer quis dolor vulputate eros ultricies elementum.</a></li>
    <li><a href="#">Praesent euismod condimentum odio.</a></li>
    <li><a href="#">Mauris hendrerit nisl in odio.</a></li>
  </ul>
 <blockquote>Aenean nisi leo, ullamcorper ut, placerat et, iaculis vel, metus. Praesent malesuada. Sed quis diam. Pellentesque mi. Suspendisse ac magna.</blockquote>
 <p>This is a sample <a href="#">inline link</a></p>';

// Make the first contents
// This is the counter to create pages until $each is arrived - change it to what you want.
// Writes at standard 1300 Contents with Sublevels.
$end=50;


$i=0;
$xi=0;
$all=0;
$dbresult = $db->Execute('TRUNCATE TABLE '.cms_db_prefix()."content");
while ($i<$end)
{
 $xi++;
 $iii=$i+1;
 if ($i<1) {$h='00001';}else{$h=str_repeat('0',5-strlen($iii)).$iii;}
 $menu='Content '.$xi;$alias='content'.$xi;
 
 $today=date("y-m-d h:m:s");
$ii=$i-1;
$pi=-1;
if ($iii == 1) {$df=1;}else{$df=0;}
$all++;
$query ="INSERT INTO ".cms_db_prefix()."content ( CONTENT_ID, CONTENT_NAME, TYPE, OWNER_ID, PARENT_ID, TEMPLATE_ID, ITEM_ORDER, HIERARCHY, DEFAULT_CONTENT, MENU_TEXT, CONTENT_ALIAS, COLLAPSED, SHOW_IN_MENU, MARKUP, ACTIVE, CACHABLE, LAST_MODIFIED_BY, CREATE_DATE, MODIFIED_DATE ) VALUES (".$xi.",'".$alias."', 'content', 1, -1, $template_id,".$xi.",'".$h."',".$df.",'".$menu."','".$alias."', null, 1, 'html', 1, 1, 1,'".$today."','".$today."' )";
$dbresult = $db->Execute($query);
 
$query ="INSERT INTO ".cms_db_prefix()."content_props ( CONTENT_ID, TYPE, PROP_NAME, PARAM1, PARAM2, PARAM3, CONTENT, CREATE_DATE, MODIFIED_DATE ) VALUES ( ".$xi.", 'string', 'content_en', null, null, null, '".$content."','".$today."','".$today."')";
$dbresult = $db->Execute($query);
 
$si=0;
$ssi=0;
$oldxi = $xi;
while ($si < 3)
{
  // make sublevel 1
  $si++;
  $hh=$h.'.'.str_repeat('0',5-strlen($si)).$si;
  $xi++;
  $all++;
  $menu='Content '.$xi;$alias='content'.$xi;
  $query ="INSERT INTO ".cms_db_prefix()."content ( CONTENT_ID, CONTENT_NAME, TYPE, OWNER_ID, PARENT_ID, TEMPLATE_ID, ITEM_ORDER, HIERARCHY, DEFAULT_CONTENT, MENU_TEXT, CONTENT_ALIAS, COLLAPSED, SHOW_IN_MENU, MARKUP, ACTIVE, CACHABLE, LAST_MODIFIED_BY, CREATE_DATE, MODIFIED_DATE ) VALUES (".$xi.",'".$alias."', 'content', 1,".$oldxi.", $template_id,1,'".$hh."',".$df.",'".$menu."','".$alias."', null, 1, 'html', 1, 1, 1,'".$today."','".$today."' )";
  $dbresult = $db->Execute($query);
  $query ="INSERT INTO ".cms_db_prefix()."content_props ( CONTENT_ID, TYPE, PROP_NAME, PARAM1, PARAM2, PARAM3, CONTENT, CREATE_DATE, MODIFIED_DATE ) VALUES ( ".$xi.", 'string', 'content_en', null, null, null, '".$content."','".$today."','".$today."')";
  $dbresult = $db->Execute($query);
  // make sublevel 2
  $ssi=0;
  $oldxi = $xi;
  while ($ssi <3)
  {
  $ssi++;
  $hhh=$hh.'.'.str_repeat('0',5-strlen($ssi)).$ssi;
  $xi++;
  $all++;
  $menu='Content '.$xi;$alias='content'.$xi;
  $query ="INSERT INTO ".cms_db_prefix()."content ( CONTENT_ID, CONTENT_NAME, TYPE, OWNER_ID, PARENT_ID, TEMPLATE_ID, ITEM_ORDER, HIERARCHY, DEFAULT_CONTENT, MENU_TEXT, CONTENT_ALIAS, COLLAPSED, SHOW_IN_MENU, MARKUP, ACTIVE, CACHABLE, LAST_MODIFIED_BY, CREATE_DATE, MODIFIED_DATE ) VALUES (".$xi.",'".$alias."', 'content', 1,".$oldxi.", 1,1,'".$hhh."',".$df.",'".$menu."','".$alias."', null, 1, 'html', 1, 1, 1,'".$today."','".$today."' )";  $dbresult = $db->Execute($query);
  $query ="INSERT INTO ".cms_db_prefix()."content_props ( CONTENT_ID, TYPE, PROP_NAME, PARAM1, PARAM2, PARAM3, CONTENT, CREATE_DATE, MODIFIED_DATE ) VALUES ( ".$xi.", 'string', 'content_en', null, null, null, '".$content."','".$today."','".$today."')";
  $dbresult = $db->Execute($query);
  }

}


$i++;
}
$query="UPDATE ".cms_db_prefix()."content_seq SET id=".$all;
$dbresult = $db->Execute($query);
$query="UPDATE ".cms_db_prefix()."content_props_seq SET id=".$all;
$dbresult = $db->Execute($query);


echo 'done ! '.$all.' contents written.';
alby

Re: Idea - Page Generator

Post by alby »

versatility wrote:
<?php

ini_set('display_errors', true);
error_reporting(E_ALL);


require_once("include.php");
// Quick and dirty script
// It trunctes table content and content_props and write new contents
active error log and check again (red code)

Alby
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm
Location: Florida West Coast

Re: Idea - Page Generator

Post by versatility »

Thanks, I get this error
Fatal error: Call to a member function on a non-object in /var/www/vhosts/dmarkinc.com/httpdocs/makecontent.php on line 57
which is the line

Code: Select all

$dbresult = $db->Execute('TRUNCATE TABLE '.cms_db_prefix()."content");
I also noticed in my text editor that this section of code

Code: Select all

<?php

ini_set('display_errors', true);
error_reporting(E_ALL);

require_once("include.php");
// Quick and dirty script
// It trunctes table content and content_props and write new contents

$template_id = 18;

$content ='
is highlighted as having a syntax error?

Thanks so much.
alby

Re: Idea - Page Generator

Post by alby »

versatility wrote: Thanks, I get this error
Fatal error: Call to a member function on a non-object in /var/www/vhosts/dmarkinc.com/httpdocs/makecontent.php on line 57
which is the line

Code: Select all

$dbresult = $db->Execute('TRUNCATE TABLE '.cms_db_prefix()."content");
Object $db is not defined;

Try with (UNTESTED):
........
require_once("include.php");
// Quick and dirty script
// It trunctes table content and content_props and write new contents

global $gCms;
$db =& $gCms->GetDb();
........
Alby
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm
Location: Florida West Coast

Re: Idea - Page Generator

Post by versatility »

Well that worked! - perhaps a little too well.  I got 650 pages of content.

This comment

Code: Select all

// This is the counter to create pages until $each is arrived - change it to what you want.
references and $each variable, but the code on line 52 is actually $end - which I set to 50 and appears to have been ignored?

This will be so awesome if I can make it work!
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm
Location: Florida West Coast

Re: Idea - Page Generator

Post by versatility »

Still hoping for a solution here :)
alby

Re: Idea - Page Generator

Post by alby »

versatility wrote: Still hoping for a solution here :)
First look I count 600:

Code: Select all

$end=50;
while ($i<$end)
{
  INSERT
  $si=0;
  $ssi=0;
  while ($si < 3)
  {
    INSERT
    $ssi=0;
    while ($ssi <3)
    {
      INSERT
    }
  }
}

If you put:
while ($si < 1)
while ($ssi <1)
I think for 100

Alby
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm
Location: Florida West Coast

Re: Idea - Page Generator

Post by versatility »

Ok, I can freely admit I don't get it.  What if i wanted 20 pages, what exactly would I do? What are each of those variables controlling?
versatility
Forum Members
Forum Members
Posts: 49
Joined: Sun Sep 24, 2006 2:46 pm
Location: Florida West Coast

Re: Idea - Page Generator

Post by versatility »

Still hoping for the last little piece of this puzzle!
Post Reply

Return to “Modules/Add-Ons”