hamesh
12-16-2006, 03:56 AM
I've been posting to SD.com and was suggested I post here instead. So...
I seem to be on an SEO mission with SD. So wanted to share a little hack to show the filename and category in the page title for the Download Manager.
First you'll need a good text editor. Notepad sucks but will get you by. For hard core Un*x folks with shell access, use vim or jed or similar on the command line. To get syntax highlighting and row numbers, there's also the free Microsoft Visual Web Developer 2005 Express Edition (http://msdn.microsoft.com/vstudio/express/vwd/) or PSPad (http://www.pspad.com/).
I digress.
Open your SD ~/index.php in text editor of choice. Around line 117 in SD 2.40, find:
// ####################### ALTER TITLE AND META SETTINGS #######################
if(isset($_GET['p2_articleid']) AND ereg("^[0-9]+$", $_GET['p2_articleid']))
{
if($article = $DB->query_first("SELECT title, metakeywords, metadescription FROM " . TABLE_PREFIX . "p2_news WHERE articleid = '" . $_GET['p2_articleid'] . "'"))
{
$mainsettings['websitetitle'] .= ' - ' . $article['title'];
$mainsettings['metadescription'] .= ', ' . $article['metadescription'];
$mainsettings['metakeywords'] .= ', ' . $article['metakeywords'];
}
}
Below this, paste:
// ################### JAMES HACK TO GET FILENAME AND CATEGORY IN DM PAGE TITLE #######################
$downloadurl = explode('/', $_SERVER['REQUEST_URI']);
if(isset($_GET['p13_sectionid']) AND ereg("^[0-9]+$", $_GET['p13_sectionid']))
{
{
$sectionname = $DB->query_first("SELECT name FROM " . TABLE_PREFIX . "p13_sections WHERE sectionid = '$downloadurl[3]'");
}
if(isset($_GET['p13_fileid']) AND ereg("^[0-9]+$", $_GET['p13_fileid']))
{
{
$filetitle = $DB->query_first("SELECT title FROM " . TABLE_PREFIX . "p13_files WHERE fileid = '$downloadurl[5]'");
}
$mainsettings['websitetitle'] .= ' - ' . $filetitle['title'];
}
$mainsettings['websitetitle'] .= ' - ' . $sectionname['name'];
}
Boom. Filename and categoryin Download Manager page titles. See http://www.belchfire.net/themes/p13_sectionid/3 (category) and http://www.belchfire.net/themes/p13_sectionid/3/p13_fileid/13 (file) for examples.
Notes. This assumes you are using Friendly URLs. Can work without Fancy URLs enabled but would require changes to $fileurl (QUERY_STRING and likely '=' as array separator). And you're not using a cloned DM but easily adapted.
Similar method could be used to enable filename and categories in title for other modules, such as Image Gallery. Obviously not ideal, but that's why it's a hack ;)
No reason couldn't use same method to update meta keywords and description also. Stay tuned.
I seem to be on an SEO mission with SD. So wanted to share a little hack to show the filename and category in the page title for the Download Manager.
First you'll need a good text editor. Notepad sucks but will get you by. For hard core Un*x folks with shell access, use vim or jed or similar on the command line. To get syntax highlighting and row numbers, there's also the free Microsoft Visual Web Developer 2005 Express Edition (http://msdn.microsoft.com/vstudio/express/vwd/) or PSPad (http://www.pspad.com/).
I digress.
Open your SD ~/index.php in text editor of choice. Around line 117 in SD 2.40, find:
// ####################### ALTER TITLE AND META SETTINGS #######################
if(isset($_GET['p2_articleid']) AND ereg("^[0-9]+$", $_GET['p2_articleid']))
{
if($article = $DB->query_first("SELECT title, metakeywords, metadescription FROM " . TABLE_PREFIX . "p2_news WHERE articleid = '" . $_GET['p2_articleid'] . "'"))
{
$mainsettings['websitetitle'] .= ' - ' . $article['title'];
$mainsettings['metadescription'] .= ', ' . $article['metadescription'];
$mainsettings['metakeywords'] .= ', ' . $article['metakeywords'];
}
}
Below this, paste:
// ################### JAMES HACK TO GET FILENAME AND CATEGORY IN DM PAGE TITLE #######################
$downloadurl = explode('/', $_SERVER['REQUEST_URI']);
if(isset($_GET['p13_sectionid']) AND ereg("^[0-9]+$", $_GET['p13_sectionid']))
{
{
$sectionname = $DB->query_first("SELECT name FROM " . TABLE_PREFIX . "p13_sections WHERE sectionid = '$downloadurl[3]'");
}
if(isset($_GET['p13_fileid']) AND ereg("^[0-9]+$", $_GET['p13_fileid']))
{
{
$filetitle = $DB->query_first("SELECT title FROM " . TABLE_PREFIX . "p13_files WHERE fileid = '$downloadurl[5]'");
}
$mainsettings['websitetitle'] .= ' - ' . $filetitle['title'];
}
$mainsettings['websitetitle'] .= ' - ' . $sectionname['name'];
}
Boom. Filename and categoryin Download Manager page titles. See http://www.belchfire.net/themes/p13_sectionid/3 (category) and http://www.belchfire.net/themes/p13_sectionid/3/p13_fileid/13 (file) for examples.
Notes. This assumes you are using Friendly URLs. Can work without Fancy URLs enabled but would require changes to $fileurl (QUERY_STRING and likely '=' as array separator). And you're not using a cloned DM but easily adapted.
Similar method could be used to enable filename and categories in title for other modules, such as Image Gallery. Obviously not ideal, but that's why it's a hack ;)
No reason couldn't use same method to update meta keywords and description also. Stay tuned.