Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 3
Opening link in new window
 
fbords
Jr. Member
 
Total Posts:  9
Joined:  2008-10-30
 

I changed one of the default callouts to a map of my physical store location. I successfully changed the link it points to, however I’d like it to open in a new window. The line i need help with is:

<action method="setLinkUrl"><url>http://www.mylink.com</url></action>

what’s the equivelant to target="_blank" and where in the tag above does it go?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Discovery
Enthusiast
 
Total Posts:  767
Joined:  2007-12-29
 

Look at how the other callout is done - you can put a <a href> tag around the image or whatever html you have in there.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Claudio Vargas
Jr. Member
 
Total Posts:  22
Joined:  2007-12-23
 

you could also use this

<a href="#" target="_blank">link here</a>

this will open the link on a different tab or window

 
Magento Community Magento Community
Magento Community
Magento Community
 
fbords
Jr. Member
 
Total Posts:  9
Joined:  2008-10-30
 

yea, but how do you do it when the image link is structured like this?

<action method="setImgSrc"><src>images/media/col_left_callout.jpg</src></action>
<
action method="setImgAlt" translate="alt" module="catalog"><alt>Alt Text</alt></action>
<
action method="setLinkUrl"><url>http://www.mylink.com</url></action>
 
Magento Community Magento Community
Magento Community
Magento Community
 
LarMan128
Jr. Member
 
Total Posts:  14
Joined:  2008-09-14
 

Did you find a solution to this? i am having a similar problem. I would like one of my top links which is in customer.xml to open in a new window and cant figure out how.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
megamagento
Jr. Member
 
Total Posts:  11
Joined:  2009-03-09
 

Has anyone found an answer for this yet? I’m having exactly the same issue. I’ve tried everything I can think of and searching the net provides no answers.

Like others here I want the link to open in a new (blank) window. How can it be done when working with this structure:

<block type="core/template" after="-" name="left.permanent.callout-2" template="callouts/left_col.phtml">
                <
action method="setImgSrc"><src>images/media/col_left_callout-2.jpg</src></action>
                <
action method="setImgAlt" translate="alt" module="catalog"><alt>some-external-website</alt></action>
                <
action method="setLinkUrl"><url>http://www.some-external-website.com</url></action>
            
</block>

Or this structure for opening internal pages in a new window, if it is possible:

<action method="addLink" translate="label title"><label>Wholesale</label><url>wholesale</url><title>Wholesale</title><prepare>true</prepare></action>

It can’t be as difficult as I’m making it surely!

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Chris Nudd
Jr. Member
 
Total Posts:  28
Joined:  2008-05-17
 

Any news on this? Don’t think opening a blank page from a callout should be this difficult. I’m trying to open an online form and a “push to call” on the first callout and open an information request form on the second. Any suggestions?

I get this error on the code below:

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 55: parser error : EntityRef: expecting ‘;’ in /home/virtualb/public_html/rp3000/app/code/core/Mage/Core/Model/Layout/Update.php on line 294
Trace:
#0 /home/virtualb/public_html/rp3000/app/code/core/Mage/Core/Model/Layout/Update.php(294): mageCoreErrorHandler(2, ‘simplexml_load_...’, ‘/home/virtualb/...’, 294, Array)
#1 /home/virtualb/public_html/rp3000/app/code/core/Mage/Core/Model/Layout/Update.php(320): Mage_Core_Model_Layout_Update->fetchFileLayoutUpdates(’

<reference name="left">
            <
block type="core/template" after="-" name="left.permanent.callout-1" template="callouts/left_col.phtml">
                <
action method="setImgSrc"><src>images/media/col_left_callout-1.jpg</src></action>
                <
action method="setImgAlt" translate="alt" module="catalog"><alt>Call 800.622.7670 or click to call.</alt></action>
                <
action method="setLinkUrl"><url><a href="http://www.ringcentral.com/ringme/ringme.asp?uc=DB8E753F318AB474A69830990D07178D510056696255,0,1&s;=no&v;=2" target="_blank"></url></action>
            </
block>
            <
block type="core/template" after="-" name="left.permanent.callout-2" template="callouts/left_col.phtml">
                <
action method="setImgSrc"><src>images/media/col_left_callout-2.jpg</src></action>
                <
action method="setImgAlt" translate="alt" module="catalog"><alt>POS NEEDS ANALYSIS</alt></action>
                <
action method="setLinkUrl"><url>https://forms.netsuite.com/app/site/crm/externalleadpage.nl?compid=085320&formid;=1&h;=9b4e0fc468f1bddd77ec</url></action>
            
</block>
        </
reference>
        <
reference name="right">
            <
block type="core/template" before="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>
            <
block type="core/template" name="right.permanent.callout" template="callouts/right_col.phtml"/>
        </
reference>
        <
reference name="footer_links">
            <
action method="addLink" translate="label title" module="catalog" ifconfig="catalog/seo/site_map"><label>Site Map</label><url helper="catalog/map/getCategoryUrl" /><title>Site Map</title></action>
        </
reference>

    </default>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Chris Nudd
Jr. Member
 
Total Posts:  28
Joined:  2008-05-17
 

sorry, double post.

 
Magento Community Magento Community
Magento Community
Magento Community
 
megamagento
Jr. Member
 
Total Posts:  11
Joined:  2009-03-09
 

Bump!

Has anyone worked out how to do this yet? If so, please share how you did it!

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Klimek
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2008-09-01
Essen
 

I solved this by a small trick.

I modified the left_col.phtml so that all links with http will open a new window an all links without will be open in the same ... a magento solution is not provided.

 
Magento Community Magento Community
Magento Community
Magento Community
 
megamagento
Jr. Member
 
Total Posts:  11
Joined:  2009-03-09
 

@Klimek

Good to hear that you have solved it, but any chance you could share how you did it in left_col.phtml?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
spideyh2003
Jr. Member
 
Total Posts:  2
Joined:  2009-08-19
 
Mega Magento - 02 September 2009 05:26 AM

@Klimek

Good to hear that you have solved it, but any chance you could share how you did it in left_col.phtml?

Thanks

Hi, once you’re inside the “left_col.phtml” file, look for the code

<a href="<?php echo $this->getUrl($this->getLinkUrl()) ?>">
... then simply add the target="_blank" attribute.  hope this helps!
 
Magento Community Magento Community
Magento Community
Magento Community
 
Kevin Bittner
Jr. Member
 
Total Posts:  2
Joined:  2008-08-14
 

There are “magic” functions in Magento that allow you to literally create functions on the fly that handle the getting / setting of data. I have two callouts in the left column, one which points internally and one that points externally and I wanted only the external link to open in a new window. So, in page.xml layout, I added the following:

<block type="core/template" name="left.permanent.callout.survey" template="callouts/left_col.phtml">
     <
action method="setImgSrc"><src>images/survey-promo-graphic.jpg</src></action>
     <
action method="setImgAlt" translate="alt"><alt>$5 off your next order</alt></action>
     <
action method="setLinkUrl"><url>http://surveyurl.com</url></action>
     
<action method="setLinkTarget"><target>_blank</target></action>
</
block>

I added an action element with the method attribute of “setLinkTarget”, and a child element of “target” with the value of “_blank” (for my target attribute of the A tag). In left_col.phtml, I added the “target” element to the “a” element:

<a href="<?php echo $this->getLinkUrl() ?>" <?php if ($this->getLinkTarget()) echo('target="'.$this->getLinkTarget().'"'); } ?>>

Because of the “magic” functions in Magento, I was able to retrieve the value of “_blank” and insert it into my a element to open the survey in a new window. Hope this helps others!

 
Magento Community Magento Community
Magento Community
Magento Community
 
bhawin13
Jr. Member
 
Total Posts:  3
Joined:  2009-08-30
 

Following code will create link which will open in new window.

<action method="addLink" translate="label title"
                
module="customer">
                <
label>Google</label>
                <
url>
                    
http://www.google.com/
                
</url>
                <
title>Home</title>
                <
prepare />
                <
urlParams />
                <
position>100</position>
                <
liParams/> 
                
                <
a>target="_blank"</a>
            </
action>

Note:
If <liParams/> is not set whatever parameter we set for hyperlink anchor tag( <a> </a>) will be applied to <li> tag. some <liParams/> is must before <aParam> or <a>. I do not know the reason. I come to know about it by trying different ideas.

I is Magento way solution.

I hope this will help.
bhawin13

 
Magento Community Magento Community
Magento Community
Magento Community
 
rickahontas
Member
 
Total Posts:  64
Joined:  2009-09-11
oakland, ca
 

Thanks for the tip, Kevin. Exactly what I was looking for. Also added a “getLinkTitle” to the href. Here is the new left_col.phtml and right_col.phtml

<div class="block block-banner">
    <
div class="block-content">
        
<?php if (strtolower(substr($this->getLinkUrl(),0,4))==='http'): ?>
            
<a href="<?php echo $this->getLinkUrl() ?>" <?php if ($this->getLinkTarget()) echo('target="'.$this->getLinkTarget().'"'); } ?> title="<?php echo $this->getLinkTitle() ?>">
        
<?php elseif($this->getLinkUrl()): ?>
            
<a href="<?php echo $this->getUrl($this->getLinkUrl()) ?>">
        
<?php endif; ?>
        
<img src="<?php echo $this->getSkinUrl($this->getImgSrc()) ?>" alt="<?php echo $this->__($this->getImgAlt()) ?>" title="<?php echo $this->__($this->getImgTitle)) ?>" />
        
<?php if ($this->getLinkUrl()): ?>
        
</a>
        
<?php endif ?>
    
</div>
</
div>
 
Magento Community Magento Community
Magento Community
Magento Community
 
chx
Jr. Member
 
Total Posts:  16
Joined:  2010-01-18
 

Thanks for the solution.
I have copy-pasted it but got a parse error message - expecting ‘;’

Anyone knows what went wrong? =)

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 3