Recent Topics

Mambo Wrapper - User Entered Links Open in New Window

Started by on Mar 26, 2005 – Contents updated: Mar 26, 2005

Mar 26, 2005 16:34    

Hello all,

I am a newbie to B2Evo. What a powerful package! Would love to see it as a Mambo Component.

(FYI for Mambo users)
Running Mambo 4.5.1 with PHPShop. Tried MamBlog but Mamblog does not have complete structure to work properly with Mambo 4.5.1 and PHPShop. It was a choice between running Mambo 4.5.0 with a working MamBlog for 4.5.0 and a suspect PHPShop, or running Mambo 4.5.1 with a suspect Mamblog and a working PHPShop... I had to choose the latter...

Anyways, I have the Basic Skin running in a Mambo wrapper and my problem is that if a user posts any kind of link it opens in the parent window (wrapper). I would like user posted links that are entered to open in a new window.

Is this configuarble somewhere? ... any suggestions would be greatly appreciated as I am not a PHP guru (am learning though!) TIA, Brad :D

(edit)
Looked at the evo_tables and found the evo_posts $post_url field. Is there a way in PHP to post an attribute like target="_blank" when the functions_bpost.php is called?

Mar 26, 2005 17:18

nope thats "configurable" anywhere. its takes a file edit

there are a few posts talking about this, not related specifically to comments but still good reading

http://forums.b2evolution.net/viewtopic.php?t=776&highlight=comments+target+blank

if you are determined to open comment links that way, I can provide the changes or someone else will wander over here after me and do it. It can be done, obviously, just not done with a toggle on/off switch

Mar 26, 2005 17:32

THANX WHOO! Exactly what I needed was found in that post :D !

In the /b2evocore/_class_item.php


if( $add_link && (!empty($this->url)) ) 
{ 
   $title = '<a href="'.$this->url.'" target="_blank" title="link opens new window">'.$title.'</a>'; 
}

Thanx again, Brad

Mar 26, 2005 17:44

youre welcome :) that was easy!

Mar 26, 2005 18:53

Here is the next dilemma...

the user hard codes a link like http://www.theirsite.com within the body of the post... and that link opens in the parent window. (not on this board, though, links open in new window)

Where is java script that ties to the 'Link' button when adding/editing the body of a post?

found a post: http://forums.b2evolution.net/viewtopic.php?t=1744

[from post]
Or, you can use this method, which is a little more complicated, and just as valid, but complies more with the "spirit" of the w3c's recommendation, since the "rel=external" tells us some semantic relevance about the link. Of course, you might not want to have all external links open in separate windows.
1. Put 'rel="external"' in the A element.
2. Put this function in the HEAD section of the page:


<script type="text/javascript"> 
function externalLinks() 
{ 
    if (!document.getElementsByTagName) return; 
    var anchors = document.getElementsByTagName("a"); 
    for (var i=0; i<anchors.length; i++) 
    { 
        var anchor = anchors[i]; 
        if (anchor.getAttribute("href") && 
        anchor.getAttribute("rel") == "external") 
        anchor.target = "_blank"; 
    } 
} 
window.onload = externalLinks; 
</script>

If I knew where to put this snippet I could test, but don't know what file/where the REL and Javascript go? (b2edit.php, _formatting.php?)


Form is loading...

powered by b2evolution – This forum is powered by b2evolution CMS, a complete engine for your website.