News:

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

Main Menu

Improving Joomla-SMF modules

Started by kai920, October 03, 2007, 08:23:53 AM

Previous topic - Next topic

Orstio

Quote from: kai920 on October 25, 2007, 02:17:37 AM
Orstio, I emailed you a php file. Did you get it?

I used it on my live server but interesting it does NOT convert the links to SEF, whereas on localhost it does.
Nevermind, figured out it has to do with SEF Advance.

Yes, I did, but I have not had a chance to look at them.

Quote from: kai920 on November 05, 2007, 02:35:42 AM
I tried to force SEF output by using sefReltoAbs (without checking for $mosConfig_sef) but the URL still comes out non-SEF. What would be possible reasons for this?

Is it the entire URL?

sefReltoAbs in Joomla needs a relative URL as input, and will not convert absolute URLs.

So:

sefReltoAbs('index.php?option=com_smf&Itemid=99'); will convert to SEF.

sefReltoAbs('http://www.site.com/index.php?option=com_smf&Itemid=99'); will not.

kai920

#41
Quote from: Orstio on November 07, 2007, 07:24:49 PM
sefReltoAbs('index.php?option=com_smf&Itemid=99'); will convert to SEF.

1. Does a slash in front matter? i.e. will sefReltoAbs convert the following URL?

            /index.php?option=com_smf&Itemid=71&board=1.0

2. If I want to remove the first slash, would this be the recommended way:
substr( ($post['board']['href']), 1)

3. I used sefReltoAbs on 'index.php?option=com_smf&Itemid=71&action=profile;u=2', and it came out as http://localhost/option,com_smf/Itemid,71/action,profile;u,2/

The correct URL should be http://localhost/option,com_smf/Itemid,71/action,profile/u,2

Orstio

1. The leading slash definitely makes a difference.  It shouldn't be there.

2. That will work.

3. After the sefReltoAbs, you will probably have to do a str_replace for the semi-colons.  That's a quirk in SMF URLs that Joomla's SEF won't be able to interpret.

kai920

Quote from: Orstio on November 21, 2007, 12:04:55 AM
3. After the sefReltoAbs, you will probably have to do a str_replace for the semi-colons.  That's a quirk in SMF URLs that Joomla's SEF won't be able to interpret.

1. OK: for the username, I used a str_replace after sefReltoAbs to weed out the semi-colon. I got pretty close but my SEF program tacks on an extra "/" at the end of the URL. Do you know if these two URLs will cause any "penalties" in search engines?

http://localhost/option,com_smf/Itemid,71/action,profile/u,2/ vs.
http://localhost/option,com_smf/Itemid,71/action,profile/u,2

2. I was looking at this code for the new icon, and noticed that it's outputting perfect SEF URLs. Why is is that sefReltoAbs is not needed on this?

<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new">

kai920

#44
Quote from: kai920 on November 21, 2007, 05:11:06 AM
I was looking at this code for the new icon, and noticed that it's outputting perfect SEF URLs. Why is is that sefReltoAbs is not needed on this?

<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new">

1. The above code translates to the following (note the "?" in the URL). Somehow the "?" is making the difference. The URL is automatically outputted into SEF URLs on any forum page.

<a href="/index.php?option=com_smf&Itemid=71&?topic=1756.msg6719;topicseen#new"> becomes

http://localhost/option,com_smf/Itemid,71/topic,1756.msg6719/topicseen,topicseen#new

What do you think of this? It's not technically correct, but it works on any forum page - The same behavior is observed for the board URL and username URL.

2. **** However on Joomla's frontpage the URL is not "magically" SEF'd... The "?" doesn't make a difference and the URL output is http://localhost/index.php?option=com_smf&Itemid=71&?topic=1756.msg6714;topicseen#new. If I take out the ? I get a normal Joomla URL that is not SEF'd.

Orstio

QuoteIt's not technically correct, but it works on any forum page - The same behavior is observed for the board URL and username URL.

Quote**** However on Joomla's frontpage the URL is not "magically" SEF'd... The "?" doesn't make a difference and the URL output is http://localhost/index.php?option=com_smf&Itemid=71&?topic=1756.msg6714;topicseen#new. If I take out the ? I get a normal Joomla URL that is not SEF'd.

Take a look at the ob_mambofix function in the bridge.  This function is exectued on all bridge pages because it is part of the bridge component.  However, on non-bridge component pages, like the Joomla front page, it is not.

You need to make your module have correct output for non-bridge component pages, and therefore, you need to remove the leading slash.

kai920

Quote from: Orstio on November 23, 2007, 06:14:16 AM
Take a look at the ob_mambofix function in the bridge.  This function is exectued on all bridge pages because it is part of the bridge component.  However, on non-bridge component pages, like the Joomla front page, it is not.

If I sefReltoAbs this:
index.php?option=com_smf&Itemid=71&topic=1689.msg6769;topicseen#new

I get this:
option,com_smf/Itemid,71/topic,1689.msg6769;topicseen/#new

Even after I replace the ";" with a "/" and take out the "/" in front of "#" it still does not match this:
option,com_smf/Itemid,71/topic,1689.msg6769/topicseen,topicseen#new

Is ob_mambofix responsible for the double "topicseen"s?

Orstio

QuoteIs ob_mambofix responsible for the double "topicseen"s?

Yes.  It does everything necessary to make the URLs work with both Joomla and SMF.

kai920

#48
Quote from: Orstio on November 28, 2007, 07:36:17 PM
Yes.  It does everything necessary to make the URLs work with both Joomla and SMF.

I assume it's the last part of the function that's responsible for the double topicseen?... the part that comes after "// and now for SEF" (line 224)

PS. even if it's a yes, I have no idea which lines are responsible..

Orstio

It's this line:

$nqsefurl = substr($nonsefurl, 0, strpos($nonsefurl, 'option')) . preg_replace('/(\;)([^=#]*)([\;#"])/', '$1$2=$2$3', substr($nonsefurl, strpos($nonsefurl, 'option'), strlen($nonsefurl)));

kai920

Cool, thanks for the hint - even if I have 0% chance of understanding what it does, I'll give it a go  :P

Orstio

#51
It looks through the URL, starting at the point where it finds "option", then replaces any set of characters surrounded by two semi-colons or a semi-colon and a "#" without a "=" or a "#" in the string with itself twice with a "=" in between.

Simply, it turns ";topicseen#" into ";topicseen=topicseen#".  It does the same for things like posting a poll (poll=poll).

Note:  In the old 3.1x bridges, this was done by a lookup in an array of strings that would need to be duplicated.  In the new SMF 1.1 bridges, I switched to a regex, because it is not only faster than the array lookup, but it also accounts for strings that are added by third party SMF mods.

kai920

Thanks for the explanation :)

Here's what I've come up with. I haven't tried to "fix" this. hey if it works...



$nqsefurl = substr($post['href'], 0, strpos($post['href'], 'option')) . str_replace("?", "", substr($post['href'], strpos($post['href'], 'option')));

          if (!empty($mosConfig_sef) && $mosConfig_sef == '1')
        {
          $nqsefurl = substr($nqsefurl, 0, strpos($nqsefurl, 'option')) . preg_replace('/([img alt=;)]http://www.simplemachines.org/community/Smileys/simple/wink.gif[/img]([^=#]*)([;#"])/', '$1$2=$2$3', substr($nqsefurl, strpos($nqsefurl, 'option'), strlen($nqsefurl)));
         
          $sefurl = sefReltoAbs(substr($nqsefurl,strpos($nqsefurl, 'index')));
        $sefurl = str_replace(";", "/", $sefurl);
        $sefurl = str_replace("/#", "#", $sefurl);
        }
   
         echo '<tr><td valign="top"><a href="', ($mosConfig_sef == 1 ? $sefurl : $nqsefurl) , '">', $post['subject'], '</a> ';


This gives identical SEF and non-SEF URLs on the non-forum pages :)


Advertisement: