Pretty URLs

Started by SMFHacks.com Team, January 31, 2007, 10:56:43 AM

Previous topic - Next topic

bianca007

Quote from: Dannii on April 10, 2008, 02:26:13 AM
Those are old instructions... check the first post. You don't need an example.htaccess file anymore, nor is there an extension-none package. And no custom themes are fine. As to your bridge... no idea, depends how it was made.

thanks for reponding :)

Which section of the admin area can I find this?
    * Enable the filters in the new Pretty URLs page

Dannii

It has it's own page, which will be listed in the side column.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Harvest

Here is (I guess) the function responsible for generating the XML URLs, it already has some URL trimming:


function template_XMLDisplay() {
global $context, $scripturl, $modSettings;

// Test to see if Joomla! is here...
if (defined('_VALID_MOS' )) {
global $mosConfig_live_site, $Itemid, $mosConfig_sef;
$myurl = ($mosConfig_sef=='1' ? '' : $mosConfig_live_site. '/') . 'index.php?option=com_smf&Itemid=' . $Itemid;
$mark = '&';
}
// And if its not here, create a false function...
else {
$myurl = $scripturl;
$mark = '?';
function sefReltoAbs($string) {
global $modSettings, $scripturl;
if (empty($modSettings['queryless_urls']) || $string == $scripturl)
return $string;
$string = str_replace('?board=', '/board,', $string);
$string = str_replace('?topic=', '/topic,', $string);
$string = $string . '.html';
return $string;
}
}


echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">';

echo '
<url>
<loc>', sefReltoAbs($myurl), '</loc>
<lastmod>', $context['sitemap']['main']['time'], '</lastmod>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>';

if (isset($context['sitemap']['board']))
foreach ($context['sitemap']['board'] as $board)
echo '
<url>
<loc>', sefReltoAbs($myurl . $mark . 'board=' . $board['id']), '</loc>
<lastmod>', $board['time'], '</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>';

if (isset($context['sitemap']['topic']))
foreach ($context['sitemap']['topic'] as $topic)
echo '
<url>
<loc>', sefReltoAbs($myurl . $mark . 'topic=' . $topic['id']), '</loc>
<lastmod>', $topic['time'], '</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>';


echo '
</urlset>';

}


Where do You suggest putting Your string replace ?
Regards

Dannii

Not the template, you need to edit the source file.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Harvest

Hmmm can't get it to work :/ This is the XML Display function:

function XMLDisplay() {
global $db_prefix, $context, $user_info, $modSettings;

$context['sub_template'] = 'XMLDisplay';

// Setup the main forum url...
$context['sitemap']['main'] = array('time' => date_iso8601());



// Get our information from the database
$request = db_query("
SELECT b.ID_BOARD, m.posterTime
FROM {$db_prefix}boards as b, {$db_prefix}messages as m
WHERE m.ID_MSG = b.ID_LAST_MSG
AND $user_info[query_see_board]
ORDER BY m.posterTime DESC", __FILE__, __LINE__);

// And assign it to an array
while ($row = mysql_fetch_assoc($request))
{
$context['sitemap']['board'][] = array(
'id' => $row['ID_BOARD'] . '.0',
'time' => date_iso8601($row['posterTime']),
);
}

// Free the result.
mysql_free_result($request);

// Get the right information
$request = db_query("
SELECT t.ID_TOPIC, m.posterTime
FROM {$db_prefix}messages as m, {$db_prefix}topics as t, {$db_prefix}boards as b
WHERE m.ID_MSG = t.ID_LAST_MSG
AND b.ID_BOARD = m.ID_BOARD
AND $user_info[query_see_board]
ORDER BY m.posterTime DESC
LIMIT $modSettings[sitemap_topic_count]", __FILE__, __LINE__);


// Assign it to the array
while ($row = mysql_fetch_assoc($request))
{
$context['sitemap']['topic'][] = array(
'id' => $row['ID_TOPIC'] . '.0',
'time' => date_iso8601($row['posterTime']),
);
}

// Free the result
mysql_free_result($request);

 
}



The 'normal' URLs (not in the XML but HERE) work great in this mod, so I thought it must be something  wrong with the rendering of the XML itself.
Thanks for help.
Regards

Dannii

Okay, try adding this after the last mysql_free_result($request); there:
// Pretty URLs need to be rewritten
ob_start('ob_sessrewrite');
$context['pretty']['search_patterns'][] = '~(<loc>)([^#<]+)~';
$context['pretty']['replace_patterns'][] = '~(<loc>)([^<]+)~';
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Harvest

Ok, I 've done that. I can't see any difference :)

Dannii

Hmm, I think you must still have SMF's SEF URLs option turned on. Edit ModSettings.php and search for "Pretty URLs mod - disable the default queryless URLs". Uncomment the following line. Then turn it off in the admin panel. And just for luck, try emptying the pretty_urls_cache table.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Harvest

That was IT You rule mate , thanks very much :)

Dannii

"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

bianca007

Quote from: Dannii on April 10, 2008, 02:54:45 AM
It has it's own page, which will be listed in the side column.

Got it :)
In case anyone has trouble and uses a custom theme, you need to apply the default skin first so that you can see the option in the admin area. After activating the url's you can switch back to your regular skin.

Dannii

Really? What problems did you have in your custom theme?
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

SA™

ohboy i need help  :D

just installed this mod enabled it and now my forum is dead

Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

If you think this is a server error, please contact the webmaster.

Error 500
waynesworld.kicks-ass.net
04/11/08 05:28:48
Apache/2.2.6 (Win32) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5

smf 2.0 bta 3 public
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Dannii

Follow the instructions here to disable the mod: http://code.google.com/p/prettyurls/wiki/TroubleShooting
And of course check all your error logs. I haven't tested 2.0 support that thoroughly, so if you can provide more information I might be able to fix it.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

SA™

 http://waynesworld.kicks-ass.net/forum/index.php?action=admin;area=pretty;sesc 
8: Undefined index: pretty_enable_filters
File: C:/*****/htdocs/forum/Sources/QueryString.php
Line: 518 



http://waynesworld.kicks-ass.net/forum/index.php?action=admin;area=pretty;sesc 
8: Undefined index: pretty_enable_filters
File: C:/******/htdocs/forum/Sources/PrettyUrls.php
Line: 96 

http://waynesworld.kicks-ass.net/forum/index.php?action=admin;area=pretty;sesc 
8: Undefined index: pretty_enable_filters
File: C:/*****/htdocs/forum/Sources/PrettyUrls.php
Line: 60 


http://waynesworld.kicks-ass.net/forum/index.php?action=admin;area=index;sesc 
8: Undefined index: pretty_enable_filters
File: C:/******/htdocs/forum/Sources/QueryString.php
Line: 518 

thats all the errors i see

when i first enable it i get
server error 500
i think it hta access side meaning this i deleted the htacesse fiile and could get into  forum just could not read topics


http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Dannii

Using phpMyAdmin add a row to the settings table with variable=pretty_enable_filters and value=0.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

SA™

Quote from: Dannii on April 11, 2008, 02:09:02 AM
Using phpMyAdmin add a row to the settings table with variable=pretty_enable_filters and value=0.

ok i goto phpmyadmin found the smf settings table how do i add the row i click on insert
but for the varible i see a drop down box but doesnt have pretty_enable_filters  am i doing it right?
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Dannii

It should look like the screenshot below.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

SA™

got this


Error
SQL query: 

INSERT INTO `forum`.`smf_settings` (

`variable` ,
`value`
)
VALUES (
'pretty_enable_filters', '0'
)

MySQL said: 

#1062 - Duplicate entry 'pretty_enable_filters' for key 1

http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Dannii

Well you shouldn't get those errors any more then. :)
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Advertisement: