<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Front-End Editing and Permalinks</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Front-End-Editing-and-Permalinks-79656</link>
        <description></description>
        <pubDate>Mon, 20 Apr 2026 06:16:06 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Front-End-Editing-and-Permalinks-79656" rel="self" type="application/rss+xml" />

                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234761#post2234761</link>
          <description><![CDATA[<p>Greg -</p>
<p>I added this to save.php to create the new page name:</p>
<p><code>$_REQUEST['permalink']  = $colsToValues['permalink']."-".$newRecordNum;</code></p>
<p>Then, if the user edits the page, I added this to edit.php:</p>
<p><code>$string = strtolower($_REQUEST['name']);<br /> $string = preg_replace("/[^a-z0-9_\s-]/", "", $string);<br /> $string = preg_replace("/[\s-]+/", " ", $string);<br /> $_REQUEST['permalink'] = preg_replace("/[\s_]/", "-", $string);</code></p>
<p>Works really well!</p>
<p>Thanks for your help,</p>
<p>:0D</p>
<p>Perchpole</p>]]></description>
          <pubDate>Thu, 14 Aug 2014 17:31:36 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234761#post2234761</guid>
        </item>
                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234760#post2234760</link>
          <description><![CDATA[<p>Greg -</p>
<p>I think I've got it. The script wasn't running because I was providing a default name for the permalink. You can only do this once! If you try again it will reject the name because it already exists in the database.</p>
<p>What I need to do is (in the short term) find a way to append a random value to the end of my given permalink - to make it unique.</p>
<p>I'm creating a new page every time - so what would work best?</p>
<p>new-page_000001</p>
<p>new-page-000002</p>
<p>etc...?</p>
<p>Perch</p>]]></description>
          <pubDate>Thu, 14 Aug 2014 17:09:06 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234760#post2234760</guid>
        </item>
                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234759#post2234759</link>
          <description><![CDATA[<p>Yes!</p>]]></description>
          <pubDate>Thu, 14 Aug 2014 16:46:20 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234759#post2234759</guid>
        </item>
                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234758#post2234758</link>
          <description><![CDATA[<p>When I was testing I had a similar issue, which I resolved by enabling the permalinks plugin, have you got the permalinks plugin enabled at the moment?</p>
<p>Cheers,</p>
<p>Greg</p>]]></description>
          <pubDate>Thu, 14 Aug 2014 16:44:42 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234758#post2234758</guid>
        </item>
                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234757#post2234757</link>
          <description><![CDATA[<p>Greg -</p>
<p>With the <strong>permalink_cms_onSaveUpdatePermalinks</strong> line in the code it simply will not run.</p>
<p>If the line is removed a new page is added as expected.</p>
<p>:0/</p>
<p>Perch</p>]]></description>
          <pubDate>Thu, 14 Aug 2014 16:42:31 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234757#post2234757</guid>
        </item>
                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234756#post2234756</link>
          <description><![CDATA[<p>Hey Perch, </p>
<p>Are you getting any errors? Or is it generating a 'false positive', where no errors are displayed, but it isn't actually updating the record?</p>
<p>Cheers,</p>
<p>Greg</p>]]></description>
          <pubDate>Thu, 14 Aug 2014 16:39:28 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234756#post2234756</guid>
        </item>
                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234755#post2234755</link>
          <description><![CDATA[<p>Thanks, greg - but it still won't run!</p>
<p>The bottom of the code looks like this now...</p>
<p><code>  ......<br />  $colsToValues['permalink']        = "newpage";<br />   <span style="color:#339966;">$_REQUEST['permalink']            = $colsToValues['permalink'];</span><br />   <br />   $newRecordNum = mysql_insert($tablename, $colsToValues, true);<br />   <br />   $isNewRecord = true;<br />   $oldRecord   = array();<br />   <br />   $GLOBALS['escapedTableName'] = mysql_escape( $TABLE_PREFIX . $tablename );<br />   $GLOBALS['schema']           = loadSchema($tablename); // fake currently loaded schema<br />   if (!$GLOBALS['schema']) { die("Invalid table name '" .htmlencode($tablename). "'"); }<br />   include_once(SCRIPT_DIR . '/lib/menus/default/common.php'); // load category menu functions <br />   updateCategoryMetadata();<br />   <br />   <span style="color:#339966;">mysql_update($tableName, $newRecordNum, null, array('permalink' =&gt; $_REQUEST['permalink']));</span><br />   permalink_cms_onSaveUpdatePermalinks($tableName, $isNewRecord, $oldRecord, $newRecordNum);</code></p>

<p>I added the hi-lighted lines - but something isn't right!</p>
<p>:0/</p>
<p>Perch</p>]]></description>
          <pubDate>Thu, 14 Aug 2014 16:31:42 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234755#post2234755</guid>
        </item>
                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234754#post2234754</link>
          <description><![CDATA[<p>Hey Perch,</p>
<p>I think you might need to set the permalink into the request array, but everything else looks correct.</p>
<p><code>  $tablename                        = 'pages';<br />  $recordNum                        = null;<br />  $where                            = null;<br />  $colsToValues                     = array(); // these fields get automatically mysql escaped unless you end fieldname with =<br />  $colsToValues['createdDate=']     = 'NOW()';<br />  $colsToValues['createdByUserNum'] = @$CURRENT_USER['num'];<br />  $colsToValues['name']             = 'New Page';<br />  $colsToValues['permalink']        = "newpage";<br /><span style="color:#008000;">  $_REQUEST['permalink']            = $colsToValues['permalink'];</span><br />          <br />  $newRecordNum = mysql_insert($tablename, $colsToValues, true);<br />          <br />  $isNewRecord       = true;<br />  $oldRecord         = array();<br />  <br />  $GLOBALS['escapedTableName'] = mysql_escape( $TABLE_PREFIX . $tablename );<br />  $GLOBALS['schema']           = loadSchema($tablename); // fake currently loaded schema<br />  if (!$GLOBALS['schema']) { die("Invalid table name '" .htmlencode($tablename). "'"); }<br />  include_once(SCRIPT_DIR . '/lib/menus/default/common.php'); // load category menu functions <br />  <br />  permalink_cms_onSaveUpdatePermalinks($tableName, $isNewRecord, $oldRecord, $newRecordNum);<br />  updateCategoryMetadata();</code></p>
<p>The function pulls the new permalink name directly from the REQUEST array, so we have to fake the POST/GET variable by setting it manually. </p>
<p>Cheers!</p>
<p>Greg</p>]]></description>
          <pubDate>Thu, 14 Aug 2014 16:19:46 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234754#post2234754</guid>
        </item>
                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234752#post2234752</link>
          <description><![CDATA[<p>Hi, Greg -</p>
<p>Thanks for this. I very much appreciate your help.</p>
<p>I've tried to add your code to my existing code - but it doesn't seem to work.</p>
<p><code>  $tablename                        = 'pages';<br />  $recordNum                        = null;<br />  $where                            = null;<br />  $colsToValues                     = array(); // these fields get automatically mysql escaped unless you end fieldname with =<br />  $colsToValues['createdDate=']     = 'NOW()';<br />  $colsToValues['createdByUserNum'] = @$CURRENT_USER['num'];<br />  $colsToValues['name']             = 'New Page';<br />  $colsToValues['permalink']        = "newpage";<br />          <br />  $newRecordNum = mysql_insert($tablename, $colsToValues, true);<br />          <br />  $isNewRecord       = true;<br />  $oldRecord         = array();<br />  <br />  $GLOBALS['escapedTableName'] = mysql_escape( $TABLE_PREFIX . $tablename );<br />  $GLOBALS['schema']           = loadSchema($tablename); // fake currently loaded schema<br />  if (!$GLOBALS['schema']) { die("Invalid table name '" .htmlencode($tablename). "'"); }<br />  include_once(SCRIPT_DIR . '/lib/menus/default/common.php'); // load category menu functions <br />  <br />  <strong>permalink_cms_onSaveUpdatePermalinks($tableName, $isNewRecord, $oldRecord, $newRecordNum);</strong><br />  updateCategoryMetadata();</code></p>
<p>Note: This is the save code for creating a completely new page.</p>
<p>This code only works if I comment out the <strong>permalink_cms_onSaveUpdatePermalinks</strong> line.<strong><br /></strong></p>
<p>What have I missed?</p>
<p>:0/</p>
<p>Perch</p>]]></description>
          <pubDate>Thu, 14 Aug 2014 16:13:01 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234752#post2234752</guid>
        </item>
                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234738#post2234738</link>
          <description><![CDATA[<p>Hey Perch,</p>
<p>You need to use this function:</p>
<p><code>permalink_cms_onSaveUpdatePermalinks($tableName, $isNewRecord, $oldRecord, $recordNum);</code></p>
<p>If you've included the viewer_functions on the saved/edit page, then you should have access to it. </p>
<p>You'll need to call it after you've updated/saved the record. You'll also need to make sure that the field that contains the permalink is called permalink, as the function will access the value for the permalink using $_REQUEST['permalink'].</p>
<p>Finally, the function needs to be able to access the schema of the section you're editing, it does this using a global called schema. You can create this using the following code:</p>
<p><code>$GLOBALS['schema']     = loadSchema( $tableName );<br /></code></p>
<p>The variables for the function are as follows:</p>
<ul><li>tableName - The table name that is being to (looks to be category in your example).</li>
<li>$isNewRecord - Boolean value for if you're creating or editing a record. True for new, False for old.</li>
<li>$oldRecord - An array of the record before it was saved. If this is a new record just pass in an empty array, if it's an old record use the mysql_get function to get an array of the records content before you update the record with the new data.</li>
<li>$recordNum - The record num for the record.</li>
</ul><p>Here is some example code that would update a record in a blog section, and update it's permalink as well:</p>
<p><code>  <br />  // load viewer library<br />  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';<br />  $dirsToCheck = array('C:/wamp/www/','','../','../../','../../../');<br />  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}<br />  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }<br /><br />  //Set page variables<br />  $_REQUEST['permalink'] = 'test4000';<br />  $recordNum             = 6;<br />  $isNewRecord           = false;<br />  $tableName             = 'blog';<br />  $GLOBALS['schema']     = loadSchema( $tableName );<br /><br />  //Get the old record<br />  $oldRecord = mysql_get($tableName, $recordNum);<br /><br />  //Update the record<br />  mysql_update($tableName, $recordNum, null, array('permalink' =&gt; $_REQUEST['permalink']));<br /><br />  //Update the permalinks<br />  permalink_cms_onSaveUpdatePermalinks($tableName, $isNewRecord, $oldRecord, $recordNum);</code></p>
<p>Thanks!</p>
<p>Greg</p>]]></description>
          <pubDate>Thu, 14 Aug 2014 10:36:55 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234738#post2234738</guid>
        </item>
                <item>
          <title>Front-End Editing and Permalinks</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2234709#post2234709</link>
          <description><![CDATA[<p>Hello, All<br /><br />For the last few weeks I've been working on a way to add and update records through a front-end form. I've overcome a couple of issues along the way  and it seems to be coming together really well.<br /><br />The only recurring issue is the way CMSB saves records. When you save a record in the back-end editor CMSB does all sorts of magic in the background. When you update though a front-end form, on the other hand, none of that magic seems to happen! This is particularly true in the case of categories.<br /><br />Thankfully Dave gave me some code which appeared to solve many of the problems:</p>
<p><code>  // force update of category metadata for sorting (this may need to be updated in a much future version)<br />  $categoryTablename = 'category';<br />  $GLOBALS['escapedTableName'] = mysql_escape( $TABLE_PREFIX . $categoryTablename );<br />  $GLOBALS['schema']           = loadSchema($categoryTablename); // fake currently loaded schema<br />  if (!$GLOBALS['schema']) { die("Invalid table name '" .htmlencode($categoryTablename). "'"); }<br />  include_once(SCRIPT_DIR . '/lib/menus/default/common.php'); // load category menu functions <br />  updateCategoryMetadata();</code><br /><br /> This forces things like breadcrumbs and lineage to update when creating a new category through the front-end form.<br /><br /> However, it does not address the bugbear of all my problems: permalinks.<br /><br /> When I add a category through the front-end form the permalinks field does not update automatically. I am required to go into the category via the back-end editor and save it manually. Only then does the permalink field update.<br /><br /> Obviously this defeats the entire purpose of having front-end editing capability!<br /><br /> Is there a fix?</p>
<p>:0/</p>
<p>Perchpole</p>]]></description>
          <pubDate>Fri, 08 Aug 2014 03:24:58 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2234709#post2234709</guid>
        </item>
              </channel>
    </rss>
  