<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lapiz Corto &#187; plantilla</title>
	<atom:link href="https://www.lapizcorto.com/tag/plantilla/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lapizcorto.com</link>
	<description>Para esas soluciones que nunca recuerdas</description>
	<lastBuildDate>Mon, 14 Dec 2015 08:34:34 +0000</lastBuildDate>
	<language>es-ES</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>Joomla: función para obtener las posiciones de un template</title>
		<link>https://www.lapizcorto.com/joomla-funcion-para-obtener-las-posiciones-de-un-template/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=joomla-funcion-para-obtener-las-posiciones-de-un-template</link>
		<comments>https://www.lapizcorto.com/joomla-funcion-para-obtener-las-posiciones-de-un-template/#comments</comments>
		<pubDate>Wed, 04 Apr 2012 16:34:20 +0000</pubDate>
		<dc:creator><![CDATA[Jiden]]></dc:creator>
				<category><![CDATA[Joomla!]]></category>
		<category><![CDATA[funciones]]></category>
		<category><![CDATA[plantilla]]></category>

		<guid isPermaLink="false">http://www.lapizcorto.com/?p=559</guid>
		<description><![CDATA[Necesitábamos una función para cargar las posiciones disponibles en un template. Al no encontrar mucha información al respecto hemos decidido publicar la función resultante para ahorrar tiempo a quien pueda necesitarla. Usaríamos la función así: Y obtendríamos algo parecido a: Array ( [0] =&#62; debug [1] =&#62; header-top [2] =&#62; header [3] =&#62; header-bottom [4] [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Necesitábamos una función para cargar las posiciones disponibles en un template. Al no encontrar mucha información al respecto hemos decidido publicar la función resultante para ahorrar tiempo a quien pueda necesitarla.</p>
<pre class="brush: php; title: ; notranslate">
/**
* Parse templateDetails.xml and get available positions
* @author Jiden - Digital Disseny, S.L.
* @version 04/04/2012
*
* @param string $tplPath - path of the current theme
* @param boolean $nameAsKey - set position name as output array key?
*
* @return array of positions
*/
function getTplPositions($tplPath, $nameAsKey = false) {
$outputArray = array();
$templateXML = $tplPath.'/templateDetails.xml';
// try to load positions from template XML file
$xml = JFactory::getXML($templateXML);
if (is_object($xml)) {
$positions = $xml-&gt;xpath('positions/position');
if ($positions) {
foreach ($positions as $position) {
$name = (string)$position-&gt;data();
// clean name
$name = preg_replace(&quot;/(\-a|\-b|\-c|\-d|\-e|\-f)$/i&quot;, &quot;&quot;, $name);
// do not add duplicates
if(!in_array($name, $outputArray)) {
// use position name as array key?
if($nameAsKey) $outputArray[$name] = $name;
else $outputArray[] = $name;
}
}
}
}
return $outputArray;
}
</pre>
<p>Usaríamos la función así:</p>
<pre class="brush: php; title: ; notranslate">
$tplPath = JPATH_SITE . '/templates/' . $this-&gt;template;
$positions = getTplPositions();
print_r($positions);
</pre>
<p>Y obtendríamos algo parecido a:</p>
<pre>Array
(
    [0] =&gt; debug
    [1] =&gt; header-top
    [2] =&gt; header
    [3] =&gt; header-bottom
    [4] =&gt; topmenu
    [5] =&gt; rsidebar-top
    [6] =&gt; rsidebar
    [7] =&gt; rsidebar-bottom
    [8] =&gt; lsidebar-top
    [9] =&gt; lsidebar
    [10] =&gt; lsidebar-bottom
    [11] =&gt; main-top
    [12] =&gt; main
    [13] =&gt; main-bottom
    [14] =&gt; component-top
    [15] =&gt; component
    [16] =&gt; component-bottom
    [17] =&gt; footer-top
    [18] =&gt; footer
    [19] =&gt; footer-bottom</pre>
<p>Esperamos haberte ahorrado algo de tiempo.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.lapizcorto.com/joomla-funcion-para-obtener-las-posiciones-de-un-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
