Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-02-26 16:02:02

chroustt
New Member
Registered: 2008-02-26
Posts: 1

open links of category_list in new window

Hi,
I have a problem with this code:

<txp:if_section name=“fotogalerie”>
<div style=“position:relative; float:left; width:320px;”>
<txp:category_list label=”“ break=“p” labeltag=“h2” section=“fotogalerie” this_section=“0” type=“image” exclude=“Site-design” />
</div>
<txp:if_category>
<txp:article form=“default” listform=“default” pgonly=“0” status=“4” />
<txp:image_gal wraptag=“div” class=“galerie” break=“div” />
</txp:if_category>
</txp:if_section>

I need to open links of category_list in new window. Is it possible?

Html code of the result is:
<div style=“position:relative; float:left; width:320px;”>
<p>
<a href=“http://www.psup.cz/fotogalerie/?c=1”>Projektový servis UP</a></p>
<p>
<a href=“http://www.psup.cz/fotogalerie/?c=498”>Infoden k programu People 6.3.2007</a></p>
<p>
<a href=“http://www.psup.cz/fotogalerie/?c=499”>PS UP CUP 7.2.2007</a></p>
<p>
</p>
</div>

Thank you very much for help!
Tomas

Offline

#2 2008-02-26 17:08:28

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: open links of category_list in new window

Use JavaScript that is targeted to those links and opens them to new windows or simply jquery

$("a").click(function () {$(this)./* Your opening rules */ });

Offline

#3 2008-02-27 04:39:26

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: open links of category_list in new window

Like Gocom said, do it with JavaScript.

Template (abbreviated)

<div id="category_list">
    <txp:category_list label="" break="p" labeltag="h2" section="fotogalerie" this_section="0" type="image" exclude="Site-design" />
</div>

JavaScript

Throw this in an external JS file:

function categoryLinks(containerId) {
	var container = document.getElementById(containerId);
	if (!container) return;
	var link = container.getElementsByTagName('a');
	for (i = 0; i < link.length; i++) {
		link[i].setAttribute('target', '_blank');
	};
};

window.onload = function() {
	categoryLinks('category_list');
	//if you're already firing off other JS functions, use addLoadEvent or addEvent
};

Offline

Board footer

Powered by FluxBB