News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Pretty URLs

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

Previous topic - Next topic

au8ust

Thanks Dannii!

It seems working fine now ;)

salguod

Upgraded to 0.8 and it's working fine.  Like the dedicated settings area, however there is no longer a place to set the base URL, is that right or did I just miss it?  Not a big deal for me now.

The other thing I noticed is that the move from 0.7 to 0.8 changed the URLs.  The URLs from 0.7 ended in a /0 (I think) and the ones in 0.8 don't.  Again, not a big deal for me as this is a private forum and not indexed (and not actually open yet), but changing URLs on long standing posts would be bad for others.

Dannii

Quotehowever there is no longer a place to set the base URL, is that right or did I just miss it?
Yeah I haven't added one yet. Not quite sure of the wording for it... it's more of a fake subdirectory setting. Sort of.

QuoteThe other thing I noticed is that the move from 0.7 to 0.8 changed the URLs.  The URLs from 0.7 ended in a /0 (I think) and the ones in 0.8 don't.  Again, not a big deal for me as this is a private forum and not indexed (and not actually open yet), but changing URLs on long standing posts would be bad for others.
This is true, however as the mod is a beta (and 0.8 isn't even properly published yet!) you have to at least be accepting of changes.
"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."

lonrot

#1223
Quote from: Dannii on February 27, 2008, 02:45:02 AM
lonrot, when you upgraded to 0.8, did you delete the database settings first?
If you want to disable it, run this query in phpmyadmin:UPDATE smf_settings SET value = '0' WHERE variable = 'pretty_enable_filters'

Thanks Dannii, Now the site works fine. But the 404 error in the boards is still there.
What can you suggest?

PS: The URL fragment for boards doesn't work for me either.

salguod

Quote from: Dannii on February 27, 2008, 09:19:41 AMThis is true, however as the mod is a beta (and 0.8 isn't even properly published yet!) you have to at least be accepting of changes.

No worries, I understand, just wanted to point it out.  Just out of curiosity, are planning to revert to the old paths upon actual release of 0.8?

Dannii

lonrot, I think there must be some problem with your server, because for noone else does it keep the escaping back slashes...

salguod, no I'll keep it the new way.
"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."

lonrot

I don't think so Dannii. I just moved to a new server and the problem came along aswell.

vhs

#1227
Hello, great job (0.8 ) but i have some request:
- is there any way to include specific for every topic and board keywords into meta tags ?
Mod already include description into meta tags but there are not keyword support (only standard smf keywords - same pod every topic).

Such improvement is included already into "seo4smf" mod but this mod are not working too good.
Keywords can be taken from topic title + text or board title

I think it will be very important for seo.
Dating online [nofollow]

Dannii

lonrot, if you completely uninstall the mod (use the uninstall tool if you like), and then reinstall 0.8, does the problem remain?

vhs, no I'm not interested in doing anything will silly meta tags. I don't want this mod to be filled with bloat.
"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."

vhs

Hmm, i think meta tags are pretty important for seo and site optimizing.
Pity.
Dating online [nofollow]

Dannii

Well you can write/use another mod, or just edit your templates manually.
"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."

lonrot

Thanks Dannii, the problem is finally solved with that php you gave me.
The only thing no good is the pretty url for members, but I can live without it.
:D

au8ust

Dannii, is it possible have member ID in pretty url for member? ex. /profile/1-admin/

Dannii

Why would you want that? (And yes it is but you'd have to edit the templates and rewrite rules manually.)
"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."

au8ust

Quote from: Dannii on February 29, 2008, 01:04:25 AM
Why would you want that? (And yes it is but you'd have to edit the templates and rewrite rules manually.)
Because I don't what ID a username has LOL

Thanks for the suggestion

Dannii

Sorry, you'd have to edit the filter function and rewrite rules manually, not any of the templates!
"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."

viulian

I found some time to upgrade pretty url on my forums - I just did so on my test machine, and it works! Super!
I also like the new admin interface for it :) [I'm using the prettyurls-base_20071230.tar.gz version]

I have a couple of questions:

a) By default, it will prettyfy the actions. It's ok with me, but I cannot get to the 'Packages' section in the admin page. All other sections seem to work ok ('Features and Options', 'Server settings', etc) but 'Packages' redirects me to the main page of the forum.
This is not an issue for me, I disabled the pretty for admin actions anyway, as I like to see the actions in browser and edit them by hand (I have some I created myself and I just edit one of the admin URL to run them).

b) I am using a plugin named 'Rename Topics' found here on the Modification pages. It is used for batched rename of a topic (including the first post, and the 'Re: .....' posts after them).
However, when I have pretty url active, it doesn't seem to work.

Is there a quick fix - if you guys can spot it, i'd be glad not to have to dig in myself :)
I assume the issue is around:

// Define ID_TOPIC.
$ID_TOPIC = (int)$_REQUEST['topic'];

but I'm clueless on how to modify it.
   
I've attached the method that does the rename:

function RenameTopic()
{
global $db_prefix, $txt, $func, $context, $sourcedir;

// Check if allowed to renameTopic.
isAllowedTo('rename_topic_own') || isAllowedTo('rename_topic_any');

// Load the template.
loadTemplate('RenameTopic');

// Check if a topic id is set.
if (!isset($_REQUEST['topic']) || is_array($_REQUEST['topic']))
fatal_lang_error('rename_topic_no_id');

// Load Subs-Post.php
require_once($sourcedir . '/Subs-Post.php');

// Define ID_TOPIC.
$ID_TOPIC = (int)$_REQUEST['topic'];

// Select the current subject.
$selectSubject = db_query("
SELECT m.subject, t.ID_FIRST_MSG
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t)
WHERE m.ID_TOPIC = '$ID_TOPIC'
AND t.ID_FIRST_MSG = m.ID_MSG
LIMIT 1", __FILE__, __LINE__);

// List the result.
list ($currentSubject, $ID_FIRST_MSG) = mysql_fetch_row($selectSubject);
mysql_free_result($selectSubject);

// Stripslashes and htmlspecialchars
$context['currentSubject'] = strtr(censorText(stripslashes($currentSubject)), array("\r" => '', "\n" => '', "\t" => ''));

// If renameTopic isset do the renaming.
if (isset($_POST['renameTopic2']) && !empty($_POST['subject']))
{
// Check if they have a valid session.
checkSession();

// Clean the new subject.
$_POST['subject'] = strtr(htmlspecialchars($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));

// At this point, we want to make sure the subject isn't too long.
if (strlen($_POST['subject']) > 100)
$_POST['subject'] = addslashes(substr(stripslashes($_POST['subject']), 0, 100));

// Make sure the subject fits in the tinytext of the database.
if (strlen($_POST['subject']) > 255)
$_POST['subject'] = addslashes(truncate(stripslashes($_POST['subject']), 255));

// Do the dew.
$update = db_query("
UPDATE {$db_prefix}messages
SET
subject = 'RE: $_POST[subject]'
WHERE ID_TOPIC = '$ID_TOPIC'", __FILE__, __LINE__);

// Subject w/o the prefix.
$update2 = db_query("
UPDATE {$db_prefix}messages
SET
subject = '$_POST[subject]'
WHERE ID_TOPIC = '$ID_TOPIC'
AND ID_MSG = '$ID_FIRST_MSG'
LIMIT 1", __FILE__, __LINE__);

// Check if it went through.  If so redirect.
if ($update == true && $update2 == true)
redirectexit('topic=' . $ID_TOPIC);
else
redirectexit('action=renameTopic;topic=' . $ID_TOPIC);
}

// Set the title.
$context['page_title'] = $txt['rename_topic'];

}


c) Third.. did any of the rules in .htaccess file changed from previous version 0.7 ? I do not use .htaccess to do the rewrites as I'm using nginx webserver (gave up on the apache - too big and slow for my requirements).
I just wanted to know if they changed because if they aren't, then I don't need to update my nginx.conf file :)

Thank you,

Dannii

#1237
Quotea) By default, it will prettyfy the actions. It's ok with me, but I cannot get to the 'Packages' section in the admin page. All other sections seem to work ok ('Features and Options', 'Server settings', etc) but 'Packages' redirects me to the main page of the forum.
This is not an issue for me, I disabled the pretty for admin actions anyway, as I like to see the actions in browser and edit them by hand (I have some I created myself and I just edit one of the admin URL to run them).
How strange, I'll have to look at it later, but I've never had problems like that before.

Quoteb) I am using a plugin named 'Rename Topics' found here on the Modification pages. It is used for batched rename of a topic (including the first post, and the 'Re: .....' posts after them).
However, when I have pretty url active, it doesn't seem to work.
Does setting it just to $topic work? Add it as a global of course.

Quotec) Third.. did any of the rules in .htaccess file changed from previous version 0.7 ? I do not use .htaccess to do the rewrites as I'm using nginx webserver (gave up on the apache - too big and slow for my requirements).
I just wanted to know if they changed because if they aren't, then I don't need to update my nginx.conf file :)
nginx doesn't have any per-directory config option does it? (I just googled a bit and though I saw something say it did, but can't find any more details)
Um.. well the actions rules are now generated from the list of actions, however practically, I don't think that will actually matter.
"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."

viulian

I've just hacked my forum to take back my admin page 8)
Pretty URL 0.8 is now installed and working!

However, for reasons unknown yet - but I hope to dig in later on - after the default install, I couldn't get to the admin page at all. No "index.php?action=" actions worked anymore (I mean members could not login, for example...).

Tracking down the issue, seems that somehow the $scripturl variable doesn't end in /index.php anymore - so all form's submit actions weren't pointing to the right thing - and as the action rewrite did not work - I could only get the forum front page.

I tried to edit the 'settings' table, 'pretty_filters' was changed manually from:

?action=something)";s:7:"enabled";i:1;

to

?action=something)";s:7:"enabled";i:0;

A couple of refreshes later, It still did not render properly (pretty actions filter was active - or in fact, the result on the screen showed that instead of /community/index.php?action=admin I got /community/admin

However, If I was manually typing the 'index.php?a....' stuff, i got the pages (but again, the forms actions were not ok still, so I coun't change anything in the admin part).

The temporary solution was to (and luckily I was still logged in as admin - as logging in didn't work anymore):

1) Put this in the browser address bar:
.../community/index.php?action=packages;sa=uninstall;package=prettyurls-base_20071230.tar.gz
2) I edited the pretty url module archive (SMF1.1/install.php file) and changed enabled to '0' instead of '1' (for the 'actions' part)

'actions' => array(
'id' => 'actions',
'description' => 'Rewrite Action URLs (ie, index.php?action=something)',
'enabled' => 0,

3) Reinstall the module.

Don't know yet why it happened, but I am sure that changing the setting manually in database (the pretty_filters) did not disable the actions filter.

But everything else seems to work normally so far :) and I got my sitemap.xml generated properly (SSI.php was needed so I can have access to $modSettings['pretty_board_urls'] - but I did the lookups manually for the ID_TOPIC -> pretty_url of topic) and composed the URL's that way.

I will now look into the Rename thing.

viulian

#1239
Ok, rename solved. Thanks for the tip with global $topic, it did contain the topic id :)

Here's the new code which also invalidates the pretty url cache.
Can you please tell me if it's correct (for example, do you indend to change some logic - in future versions of pretty url - which might break the code below ?)



                // Invalidate pretty url cache
                // Find out what to remove first.
                $cached_topic_result = db_query("SELECT pretty_url FROM {$db_prefix}pretty_topic_urls WHERE ID_TOPIC=$topic LIMIT 1", __FILE__, __LINE__);
                list($current_cache_value) = mysql_fetch_row($cached_topic_result);
                mysql_free_result($cached_topic_result);

                // cleanup!
                $update3 = db_query("DELETE FROM {$db_prefix}pretty_topic_urls WHERE ID_TOPIC=$topic", __FILE__, __LINE__);
                $update4 = db_query("DELETE FROM {$db_prefix}pretty_urls_cache WHERE replacement LIKE '%" . $current_cache_value . "%'", __FILE__, __LINE__);

                // Check if it went through.  If so redirect.
                if ($update == true && $update2 == true && $update3 == true && $update4 == true)
                        redirectexit('topic=' . $ID_TOPIC);
....................

Advertisement: