Miscellaneous ⇒ Search Engines ⇒ Would LEO be able to rewrite my content(enhanced) URLs? ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexSearch Engines

Would LEO be able to rewrite my content(enhanced) URLs? Reply to topic


Hi,

if I will ever get LEO working how will it rename my content managed with content(enhanced)?

At this time (without LEO) my links look like this:
www.xptweaker.de/index...amp;pid=91

Is it possible for LEO to create links with the title of the content in the URL like "xptweaker.de/.../iam_am_the_content_title.html" ?
Or will it just be renamed to ".../91.html"?

Thanks in advance,
ravel

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Apache/4.4.2/4.0.24_Debian-4.dotdeb.0-log/9.0.6.1.1


For me it is yoursite.com/Content/pid=7.html

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
-


ravel wrote
Is it possible for LEO to create links with the title of the content in the URL like "xptweaker.de/.../iam_am_the_content_title.html" ?
Or will it just be renamed to ".../91.html"?


Nope, not possible. The example Eestlane quotes is how it'll work. It's not specific to Content, all the module will work similiarly under LEO.

It is pitch black. You are likely to be eaten by a grue.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Ubuntu 12.04, Atom D525/Apache 2.2.22/MySQL 5.5.38/PHP 5.3.10/Dragonfly 9.4.0.0 CVS


Had to go and say it wasn't possible, didn't you. Dang, just begging for me to prove it's possible. Follow the instructions below to make it work. It will only work with content whos title only has the letters a-z, numbers 0-9, spaces or dashes - no other characters or it won't find the module title correctly. The code below also assume you installed the module to the modules/Content directory.

Back up your files and your database before you try this.

Change line 262 of your modules/Content/index.php file from:
echo "<tr><td class="$row_class" valign="top"><img src="modules/{$mod_dirname}/images/arrow.gif" border="0" alt="" /> <a href="".getlink("&pid=$pid")."">$title</a>"

to:
$link_title = str_replace(' ', '_', $title); echo "<tr><td class="$row_class" valign="top"><img src="modules/{$mod_dirname}/images/arrow.gif" border="0" alt="" /> <a href="".getlink("&file=$link_title")."">$title</a>"


Now, add the following after line 59 of you index.php file (yes, the one in your root folder):
if ( ('content' == $module_name) && ('index' != $file) ) { $title = str_replace('_', ' ', $file); $file = 'index'; list($pid) = $db->sql_ufetchrow('SELECT pid FROM '.$prefix."_pages WHERE title = '".Fix_Quotes($title)."'", SQL_NUM); if (intval($pid)) { $_GET['pid'] = $pid; } }

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Win, Linux/1.3.34/4.0.26, 5.0.19/4.3.10, 5.1.2, 8.1.4(PostgresSQL)/9.0.6.1, CVS


Very, very interesting and instructive, Biggles. Your posts, with hacks like these, count for true Dragonfly training. That's how I feel, and I'm sure others feel the same, too.

Now, two questions from your humble trainee.

1. What will happen when two different entries have an identical title? Right now I think we'll get some sort of error/ unintended behaviour. I don't think we will be able to get to both entries.
2. What will happen to the parts of the Content Module that do make normal use of the "&file="-construction to get included. Don't we need to exclude these from the manipulation in the root index.php?
EDIT: Hmm, I thought 'file' was somewhere in Content but I must be wrong. Found 'pid', 'cid', 'print', so far.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/Apache/5.0.24/5/9.1 CVS


Correct, it will not work with two items with the same title, it'll pull the first one from the database in every case. The file index is always used to determine the file to include if not the index page. For example, the url to your post is:
http://dragonflycms.org/Forums/viewtopic/p=104285.html#104285

That gets translated to:
http://dragonflycms.org/index.php?name=Forums&file=viewtopic&p=104285#104285

Dragonfly will then include the modules/Forums/viewtopic.php file instead of the index.php file. Any attributes after this are accessible through the $_GET var. This hack will work for the content module because there are not other included files in the modules/Content directory. If there were, then you would have to check the filenames in the index.php file to make sure you weren't trying to include one of those instead.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Win, Linux/1.3.34/4.0.26, 5.0.19/4.3.10, 5.1.2, 8.1.4(PostgresSQL)/9.0.6.1, CVS


I don't find any lines that look like

echo "<tr><td class="$row_class" valign="top"><img src="modules/{$mod_dirname}/images/arrow.gif" border="0" alt="" /> <a href="".getlink("&pid=$pid")."">$title</a>"

In the index.php files is this process changed now or something. I would love for my file names to reflect the title instead of simply a number is this possible or has the new dragonfly changed this code in some manner.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Dragonfly


You're using the wrong Content module. Use the Content Enhanced one.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Win, Linux/1.3.34/4.0.26, 5.0.19/4.3.10, 5.1.2, 8.1.4(PostgresSQL)/9.0.6.1, CVS


getlink("&file={$pid}_{$link_title}") Smile

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


Biggles wrote
Had to go and say it wasn't possible, didn't you. Dang, just begging for me to prove it's possible. Follow the instructions below to make it work. It will only work with content whos title only has the letters a-z, numbers 0-9, spaces or dashes - no other characters or it won't find the module title correctly. The code below also assume you installed the module to the modules/Content directory.

Back up your files and your database before you try this.

Change line 262 of your modules/Content/index.php file from:
echo "<tr><td class="$row_class" valign="top"><img src="modules/{$mod_dirname}/images/arrow.gif" border="0" alt="" /> <a href="".getlink("&pid=$pid")."">$title</a>"

to:
$link_title = str_replace(' ', '_', $title); echo "<tr><td class="$row_class" valign="top"><img src="modules/{$mod_dirname}/images/arrow.gif" border="0" alt="" /> <a href="".getlink("&file=$link_title")."">$title</a>"


Now, add the following after line 59 of you index.php file (yes, the one in your root folder):
if ( ('content' == $module_name) && ('index' != $file) ) { $title = str_replace('_', ' ', $file); $file = 'index'; list($pid) = $db->sql_ufetchrow('SELECT pid FROM '.$prefix."_pages WHERE title = '".Fix_Quotes($title)."'", SQL_NUM); if (intval($pid)) { $_GET['pid'] = $pid; } }


is this still valid? What is/was in the last php spot to go into the index? just one blank space? Don't wanna try this unless it works.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/Apache 2.0.54 (Fedora)/4.1.20/5.0.4/9.1.2.1


fixed the post of Biggles Wink

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


ok!!! I'll test. Another question, if I use Content_1 and Content_2 can I rename each Content folder to be something else? As in can Content_1 be Info Content_2 become Printing, etc?

I thank you for your time in answering.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/Apache 2.0.54 (Fedora)/4.1.20/5.0.4/9.1.2.1


Not working for me.

If I name the page index, then it loops, reloading Content_1/index.html If I rename it anything else, it tosses an error. I tried a couple things, none worked. this is the error:
-----------------
The URL that you requested, /Content_1/index2.html, could not be found. Perhaps you either mistyped the URL or we have a broken link.

We have logged this error and will correct the problem if it is a broken link.We're sorry, but that page modules/Content_1/index2.php does not exist
-----------------
if you go to it's original url: /pid=1.html it loads the page correctly.

the URL re-writes whether the root index.php is edited or not, and I tried the line 59 in a line above, below what I count as line 59. Doesn't make any difference.

Removing code from Content_1 till I have something that works.

Thanks for looking at it!

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/Apache 2.0.54 (Fedora)/4.1.20/5.0.4/9.1.2.1


Ok, I thought after looking at it, perhaps I made the mistake of not renaming content in the root index part to Content_1. So I put it back in, with that. It didn't work. Same error. However, when I changed Content_1 to content_1 the error changed, and becomes:

---------------
A database error has occurred

The webmaster has been notified of the error
---------------
on the top and down below says:
---------------
includes/db/db.php

* CMS Warning line 75: On /Content_1/index2.html While executing query "SELECT pid FROM dime_pages WHERE title = 'index2'" the following error occured: Table 'XXXXXXXXXX_pages' doesn't exist In: /XXXXXXXXXXXXXX/httpdocs/index.php on line: 64
----------------

BUT! I figured that out as well. here is the correct code to use to make this work in a Content_1 install:

if ( ('content_1' == $module_name) && ('index' != $file) ) { $title = str_replace('_', ' ', $file); $file = 'index'; list($pid) = $db->sql_ufetchrow('SELECT pid FROM '.$prefix."_pages_1 WHERE title = '".Fix_Quotes($title)."'", SQL_NUM); if (intval($pid)) { $_GET['pid'] = $pid; } }

the pages database call....so there you go.

I hope that gets others to where they can call the page titles in Content_1 Content 2 situtions (I will assume that adding a 2 to the if statement will make it work for each instance.

Now all I need is some way to rename the Content_1 Content_2 in the URL so I can make the site how I want it.

Thanks for your help so far, and Dragonfly Rocks!!!!!

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/Apache 2.0.54 (Fedora)/4.1.20/5.0.4/9.1.2.1


Hello,

I have a problem with the content block, I do not know where I will put it here $link_title = str_replace(' ', '_', $title);

This link Gent Site.html
But it should be This_Site.html


here my cod:
<?php /*********************************************************************** Content (Enhanced) for Dragonfly(TM) CMS ********************************************************************** Content Menu Block Copyright (C) 2005-2007 by Dark Grue Block for the Content Module that lists Content categories in a collapsible JavaScript menu. State is retained between page loads using cookies and state is validated using a hash function. Homepage: http://www.theclenchedfist.com/projects/content/ $Source: blocks/block-Content_Menu.php $ $Revision: 9.7.11 $ $Author: darkgrue (darkgrue @ iname.com) $ $Date: 2007-10-31 $ License: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***********************************************************************/ if (!defined('CPG_NUKE')) { exit; } // ************************* Display Settings ************************** // expand_all: Menu starts fully open; overrides $displaydepth setting. // TRUE - Start menu with all branches open. // FALSE - Start menu with all branches collapsed. (Default) $expand_all = FALSE; // displaydepth: How many levels deep to expose subcategories. $displaydepth = 0; // *********************** Module Instantiation ************************ // This block can reference alternative instances of its associated // module by adding an underscore followed by an integer to the name of // the file (e.g. "block-Content_Menu_2.php"). The block will // detect this and automagically configure itself. // // NOTE: // The block will check $blk_basename against its filename. // Modules that this block references MUST be configured separately // to create/reference the new instance. $blk_basename = 'block-Content_Menu'; $blk_filename = basename(__FILE__); $mod_basename = 'Content'; $matches = array(); if (preg_match("/^{$blk_basename}(?:_(\d+))?\.php$/", $blk_filename, $matches)) { $suffix = (empty($matches[1])) ? '' : "_{$matches[1]}"; $mod_dirname = $mod_basename.$suffix; } else { $content = 'ERROR'; return trigger_error("The block filename, <nobr>\"{$blk_filename}\"</nobr>, does not follow the expected instantation syntax of <nobr>\"{$blk_basename}[_<i><integer></i>].php\"</nobr>.", E_USER_WARNING); } // REQUIRED: $mod_dirname // REQUIRED: $suffix // ********************************************************************* if (empty($mod_dirname) || !file_exists(CORE_PATH."../modules/{$mod_dirname}")) { $content = 'ERROR'; return trigger_error('The expected module directory'.((empty($mod_dirname)) ? '' : ", \"{$mod_dirname}\",").' does not exist.', E_USER_WARNING); } if (!is_active($mod_dirname)) { $content = 'ERROR'; return trigger_error("The {$mod_dirname} module is inactive.", E_USER_WARNING); } // Retrieve menu cache. if ($menu = Cache::array_load('menu', $mod_dirname, FALSE)) { $content = $menu[0]; return; } global $db, $prefix; $bid = (isset($block['bid'])) ? $block['bid'] : intval($bid); $content = ''; $acc = NULL; // Retrieve active categorized content. $result = $db->sql_query("SELECT cid, pid, title FROM {$prefix}_pages{$suffix} WHERE active='1' AND cid!='0' ORDER BY title", FALSE); while (list($cid, $pid, $ptitle) = $db->sql_fetchrow($result)) { $acc[$cid][$pid] = $ptitle; } $db->sql_freeresult($result); if (count($acc) != 0) { // Avoid polluting the JavaScript namespace by prefixing the // function name with the Block ID. $content = "\n".'<script language="JavaScript" type="text/javascript"> <!-- Hide script from old browsers. function bid'.$bid.'_togglelist(img) { var ulReturn=img.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("ul"); if (ulReturn[0].style.display == "none") { img.src="modules/'.$mod_dirname.'/images/blocks/open.gif"; ulReturn[0].style.display= "block"; } else { img.src="modules/'.$mod_dirname.'/images/blocks/closed.gif"; ulReturn[0].style.display= "none"; } } // End --> </script>'."\n"; // Retrieve menu. eval("function bid{$bid}_list_menu_recursive(&\$content, \$parent = 0, \$depth = 0) { global \$db, \$prefix; // Retrieve content categories. \$result = \$db->sql_query(\"SELECT cid, title, description FROM {\$prefix}_pages_categories{$suffix} WHERE parentcid={\$parent} ORDER BY title\", FALSE); \$numrows = \$db->sql_numrows(\$result); \$menuitems = ''; \$crumb = str_repeat(' ', \$depth); if (\$numrows) { for (\$i = 0; \$i < \$numrows; \$i++) { \$row = \$db->sql_fetchrow(\$result, SQL_ASSOC); // Recursively fetch subcategories \$rowitems = bid{$bid}_list_menu_recursive(\$content, \$row['cid'], (\$depth + 1)); if (isset(\$content[\$row['cid']]) && count(\$content[\$row['cid']])) { // Print list of active article titles in this category. foreach (\$content[\$row['cid']] as \$pid => \$ptitle) { \$rowitems .= \"\$crumb <li><img src=\\\"modules/{$mod_dirname}/images/blocks/arrow.gif\\\" width=\\\"9\\\" height=\\\"9\\\" border=\\\"0\\\" alt=\\\"\\\" /> <a href=\\\"\".getlink(\"{$mod_dirname}&file=$link_title{\$ptitle}\").\"\\\">\$ptitle</a></li>\n\"; } } // Skip truly empty subcategories (no content or subcategories). if (!empty(\$rowitems)) { \$menuitems .= \$crumb.' <li><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"top\">' .\"<img src=\\\"modules/{$mod_dirname}/images/blocks/\".((".(int)$expand_all." || (\$depth < $displaydepth)) ? 'open' : 'closed').\".gif\\\" onclick=\\\"bid{$bid}_togglelist(this)\\\" style=\\\"border:0;margin:2px 3px 0 0;width:9px;height:9px;\\\" alt=\\\"\\\" /></td>\" .\"<td><b><a href=\\\"\".getlink(\"{$mod_dirname}&pa=category&cid={\$row['cid']}\").\"\\\">{\$row['title']}</a></b></td></tr></table>\n\" .\"\$crumb <ul style=\\\"\".((".(int)$expand_all." || (\$depth < $displaydepth)) ? '' : 'display:open;').\"list-style:none;margin:3px 0 0 10px;padding:0\\\" class=\\\"bid{$bid}_foldinglist\\\">\n\" .\$rowitems .\"\$crumb </ul>\n\" .\"\$crumb </li>\n\"; } } // Skip truly empty categories (no content or subcategories). if (!empty(\$menuitems) && (\$depth == 0)) { \$menuitems = \"<ul style=\\\"list-style:none;margin:3px 0 0 0px;padding:0\\\">\n\" .\$menuitems .\"</ul>\n\"; } } \$db->sql_freeresult(\$result); return \$menuitems; }"); $func = "bid{$bid}_list_menu_recursive"; $menu = $func($acc); $content .= $menu.((empty($menu)) ? '' : "<br />\n"); // Take a MD5 hash of the content up to this point so we can tell if the // menu has changed between page loads. If it has, we can't restore the // menu state. $contenthash = md5($content); // Avoid polluting the JavaScript namespace by prefixing the // function name with the Block ID. $content .= "\n".'<script language="JavaScript" type="text/javascript"> <!-- Hide script from old browsers. function bid'.$bid.'_getCookie(name) { // Get cookie routine by Shelley Powers. var search = name + "="; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search); // If cookie exists... if (offset != -1) { offset += search.length; // Set index of beginning of value. end = document.cookie.indexOf(";", offset); // Set index of end of cookie value. if (end == -1) { end = document.cookie.length; } return unescape(document.cookie.substring(offset, end)); } } return null; } var bid'.$bid.'_foldinglistarray = new Array(); if (document.getElementsByTagName) { // Build array of elements. for (i = 0; i < document.getElementsByTagName("ul").length; i++) { if (document.getElementsByTagName("ul")[i].className == "bid'.$bid.'_foldinglist") { // Append element to list. bid'.$bid.'_foldinglistarray = bid'.$bid.'_foldinglistarray.concat(document.getElementsByTagName("ul")[i]); } } } // Restore menu state. if (bid'.$bid.'_foldinglistarray.length) { if (bid'.$bid.'_getCookie("bid'.$bid.'_ContentHash") == "'.$contenthash.'") { if (bid'.$bid.'_getCookie("bid'.$bid.'_ContentMenu") != null) { var opennodes = bid'.$bid.'_getCookie("bid'.$bid.'_ContentMenu").split(" "); // Build index key for open nodes. var index = new Array(); for (i = 0; i < opennodes.length; i++) { index[opennodes[i]] = true; } for (i = 0; i < bid'.$bid.'_foldinglistarray.length; i++) { if (index[i]) { // Set block open. bid'.$bid.'_foldinglistarray[i].style.display = "block"; bid'.$bid.'_foldinglistarray[i].parentNode.firstChild.firstChild.firstChild.firstChild.firstChild.src = "modules/'.$mod_dirname.'/images/blocks/open.gif"; } else { // Set block closed. bid'.$bid.'_foldinglistarray[i].style.display = "none"; bid'.$bid.'_foldinglistarray[i].parentNode.firstChild.firstChild.firstChild.firstChild.firstChild.src = "modules/'.$mod_dirname.'/images/blocks/closed.gif"; } } } } } function bid'.$bid.'_saveState() { var opennodes = ""; for (i = 0; i < bid'.$bid.'_foldinglistarray.length; i++){ if (bid'.$bid.'_foldinglistarray[i].style.display != "none") { opennodes += " " + i; } } document.cookie = "bid'.$bid.'_ContentMenu=" + opennodes + "; path=/"; document.cookie = "bid'.$bid.'_ContentHash='.$contenthash.'; path=/"; } // IE doesn\'t support the addEventListener method, so just wrap the // onunload method to keep compatability with other scripts that // may be running on the page. var bid'.$bid.'_oldOnUnload = (window.onunload) ? window.onunload : function () {}; window.onunload = function () { bid'.$bid.'_oldOnUnload(); bid'.$bid.'_saveState(); }; // End --> </script>'; } // Retrieve active uncategorized content. $result = $db->sql_query("SELECT pid, title FROM {$prefix}_pages{$suffix} WHERE active='1' AND cid='0' ORDER BY title", FALSE); while (list($pid, $ptitle) = $db->sql_fetchrow($result)) { // Print list of active article titles in this category. $content .= "<img src=\"modules/{$mod_dirname}/images/blocks/arrow.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" /> <a href=\"".getlink("{$mod_dirname}&pa=showpage&pid={$pid}").'">'.$ptitle."</a><br />\n"; } $db->sql_freeresult($result); if ($content) { // Wrap menu in DIV element. $content = '<div align="left" style="text-align:left">'.$content.'</div>'; // Save menu cache. Cache::array_save('menu', $mod_dirname, array($content)); } else { // Invalidate block menu cache. Cache::array_delete('menu', $mod_dirname); $content = 'ERROR'; return trigger_error("Module $mod_dirname returned no content.", E_USER_NOTICE); }


I hope someone can help me

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
OS/

All times are UTC


Jump to: