artabro/site/templates/layout/func.php

63 lines
1.6 KiB
PHP
Raw Permalink Normal View History

<?php namespace ProcessWire;
2024-08-27 16:26:09 +02:00
function getConfig($paxina)
{
$configuracion = array();
foreach($paxina->configuracion as $config)
{
switch ($config->parametro_tipo->value)
{
case 'texto':
$configuracion[$config->parametro_nome] = $config->parametro_valor;
break;
case 'imaxe':
$configuracion[$config->parametro_nome] = array(
'url' => $config->parametro_imaxe->first()->url,
'descripcion' => $config->parametro_imaxe->first()->description,
'miniatura' => $config->parametro_imaxe->getTag("mini")->url
);
break;
case 'cor':
list($r, $g, $b) = sscanf($config->parametro_cor, "%02x%02x%02x");
$configuracion[$config->parametro_nome] = $r . ', ' . $g . ', ' . $b;
break;
}
}
return $configuracion;
}
function renderMigas($paxina)
{
$saida = '';
$saida .= '<h1>';
if($paxina->parents->count())
{
$saida .= $paxina->parents->implode(" &gt; ", "<a href='{url}'>{title}</a>",
array(
'append' => '&gt'
)
);
}
$saida .= $paxina->title . '</h1>';
return $saida;
}
function renderMenu($menu, $paxinas)
{
$saida = '';
$saida .= $paxinas->implode("\n", "<li><a href=\"{url}\">{title}</a></li>",
array(
'prepend' => '<nav id="' . $menu . '">' . "\n" . '<ul>' . "\n",
'append' => "\n" . '</ul>' . "\n" . '</nav>' . "\n"
)
);
return $saida;
}