[Solved] Anchor Tags Don't Work with Joomla SEF on

Started by oSa, November 23, 2006, 04:53:28 PM

Previous topic - Next topic

oSa

what was this file supposed to fix? i couldn't see any difference.

Orstio


oSa

#22
Still it doesn't make any difference. With the default smf.php, quote and inline edit works but the #new, #top and #bot are missing at the end of the links. With the other modified smf.phps neither quote & inline edit work nor #s exist.

I must say that up/down links work(they get #s at the end of links) when you go into the topic by clicking topic name, but when you click the new icon and go into the topic #s dissappear and up/down links don't work.

Orstio

Have you ever had any third party SEF engines installed?

In your includes folder there is a file named sef.php.  Can you confirm this code is there:

// check if link contained fragment identifiers (ex. #foo)
$fragment = '';
if ( isset($url['fragment']) ) {
// ensure fragment identifiers are compatible with HTML4
if (preg_match('@^[A-Za-z][A-Za-z0-9:_.-]*$@', $url['fragment'])) {
$fragment = '#'. $url['fragment'];
}
}

oSa

Yes, it is in my sef.php.

I usually try new things on my localhost first and if it works ok then i apply it to my online site.  I remember trying some 3rd party SEF engines before i've read that bridge doesn't work well with them; but i can't be sure if i've installed them to my online site. 

Orstio

What happens if you change it to this?

// check if link contained fragment identifiers (ex. #foo)
$fragment = '';
if ( isset($url['fragment']) ) {
// ensure fragment identifiers are compatible with HTML4
$fragment = '#'. $url['fragment'];
}

oSa

#26
Now we are close i think :) The links become like this, but still takes you to the top of the page:
http://www.artifm.net/component/option,com_smf/Itemid,26/topic,105.msg795#new&lang,tr

&lang,tr part seems problematic ? When i delete that part, everything works ok.

Orstio

Is it Joom!Fish that is generating that lang bit?

oSa

Yes, it's joomfish. And i forgot to say that i've tried my original smf.php not the lastest modified version you've sent me with this last code change. Was i supposed to use that one?

oSa

Sorry if you've read my last post (i've deleted now), i thought i've solved the problem but i was wrong :(

When i try to change manually
http://www.artifm.net/component/option,com_smf/Itemid,26/board,1.0#bot&lang,tr
to
http://www.artifm.net/component/option,com_smf/Itemid,26/board,1.0/lang,tr#bot
the problem is solved temporarily until i click an erroneous "new" icon link.

Orstio

You should be able to find a file named joomfish.html.php.  In that file is a function named _createHRef.

Change that entire function to this:

function _createHRef( $iso ) {
$href= "index.php";
$fragment = substr($_SERVER['QUERY_STRING'], strpos('#', $_SERVER['QUERY_STRING']), strlen($_SERVER['QUERY_STRING']));
$_SERVER['QUERY_STRING'] = substr($_SERVER['QUERY_STRING'],0,strpos('#', $_SERVER['QUERY_STRING']));
$vars = explode( "&", $_SERVER['QUERY_STRING'] );
$hrefVars = '';
if( count($vars) > 0 && $_SERVER['QUERY_STRING']) {
foreach ($vars as $var) {
if( eregi('=', $var ) ) {
list($key, $value) = explode( "=", $var);
if( $key != "lang" ) {
if( $hrefVars != "" ) $hrefVars .= "&";
$hrefVars .= "$key=$value";
}
}
}
}

if( $iso != null ) {
if( $hrefVars != "" ) $hrefVars .= "&";
$hrefVars .= "lang=$iso";
}

if( $hrefVars != "" ) {
$href .= "?$hrefVars".$fragment;
}
return sefRelToAbs( $href );
}

oSa

#31
I have changed that function, probably you have tested yourself on my site: it doesn't make any difference, still &lang,tr at the end.

It seems that only the first unread post(new icon) and latest post links have this problem.

Orstio

Sorry, had some things backwards.   ::)

function _createHRef( $iso ) {
$href= "index.php";
$fragment = substr($_SERVER['QUERY_STRING'], strpos($_SERVER['QUERY_STRING'], '#'), strlen($_SERVER['QUERY_STRING']));
$_SERVER['QUERY_STRING'] = substr($_SERVER['QUERY_STRING'],0,strpos($_SERVER['QUERY_STRING']), '#');
$vars = explode( "&", $_SERVER['QUERY_STRING'] );
$hrefVars = '';
if( count($vars) > 0 && $_SERVER['QUERY_STRING']) {
foreach ($vars as $var) {
if( eregi('=', $var ) ) {
list($key, $value) = explode( "=", $var);
if( $key != "lang" ) {
if( $hrefVars != "" ) $hrefVars .= "&";
$hrefVars .= "$key=$value";
}
}
}
}

if( $iso != null ) {
if( $hrefVars != "" ) $hrefVars .= "&";
$hrefVars .= "lang=$iso";
}

if( $hrefVars != "" ) {
$href .= "?$hrefVars".$fragment;
}
return sefRelToAbs( $href );
}

oSa

Sorry, no change. Do you think it will be better if i give up on sef :)

Orstio

You'll have the same problem without SEF.

For some reason, Joom!Fish is adding the "&lang=tr" part to the end of the URL, even if it has a fragment anchor.  What it needs to do is add that beforethe fragment, not after.

oSa

But it doesn't add &lang=tr when sef is off ??? so it works ok. If the same thing is possible with sef on, then the problem can be solved ???

Orstio

In your sef.php, is there anything added, along the lines of '&lang=' ?  I would look particularly in the sefReltoAbs function.

oSa

In sefReltoAbs function:
//multilingual code url support
if( $mosConfig_sef && ($mosConfig_mbf_content || $mosConfig_multilingual_support) && $string!='index.php' && !eregi("^(([^:/?#]+):)",$string) && !strcasecmp(substr($string,0,9),'index.php') && !eregi('lang=', $string) ) {
$string .= '&lang='. $iso_client_lang;
}

and
// lang
if ( isset( $parts['lang'] ) ) {
$sefstring .= 'lang,'. $parts['lang'].'/';
}


Orstio


oSa


Advertisement: