32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-12-25 17:51:07 +00:00

Improve layout

This commit is contained in:
chmst 2021-08-15 11:20:51 +02:00
parent 39b33103c0
commit ef3251471a

View File

@ -11,110 +11,126 @@ defined('_JEXEC') or die;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
?> if ($params->get('groupby', 0)) :
$cats = [];
$cols = $params->get('groupby_columns', 3);
<?php if ($params->get('groupby', 0)) : ?> foreach ($list as $l) :
<?php $cats = []; ?> $cats[] = array('catid' => $l->catid, 'title' => $l->category_title);
<?php $cols = $params->get('groupby_columns', 3); ?> endforeach;
<?php foreach ($list as $l) : ?>
<?php $cats[] = array('catid' => $l->catid, 'title' => $l->category_title); ?>
<?php endforeach; ?>
<?php $cats = array_values(array_map('unserialize', array_unique(array_map('serialize', $cats)))); ?>
<?php foreach ($cats as $k => $cat) : ?>
<?php $items = array(); ?>
<?php foreach ($list as $item) : ?>
<?php if ($item->catid == $cat['catid']) : ?>
<?php $items[] = $item; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php if ($cols > 1) : ?>
<?php if ($k % $cols == 0) : ?>
<div class="row row-fluid">
<?php endif; ?>
<div class="col-<?php echo (12 / $cols); ?>">
<?php endif; ?>
<?php if ($params->get('groupby_showtitle', 1)) : ?>
<h4><?php echo htmlspecialchars($cat['title'], ENT_COMPAT, 'UTF-8'); ?></h4>
<?php endif; ?>
<ul class="mod-list weblinks <?php echo $moduleclass_sfx; ?>">
<?php foreach ($items as $item) : ?>
<li>
<?php $link = $item->link; ?>
<?php
switch ($item->params->get('target', 3))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2: $cats = array_values(array_map('unserialize', array_unique(array_map('serialize', $cats))));
// Open in a popup window
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
default: foreach ($cats as $k => $cat) :
// Open in parent window $items = [];
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
}
?>
<?php if ($params->get('description', 0)) : ?>
<?php echo nl2br($item->description); ?>
<?php endif; ?>
<?php if ($params->get('hits', 0)) : ?> foreach ($list as $item) :
<?php echo '(' . $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS') . ')'; ?> if ($item->catid == $cat['catid']) :
<?php endif; ?> $items[] = $item;
</li> endif;
<?php endforeach; ?> endforeach;
</ul>
<?php if ($cols > 1) : ?>
</div>
<?php if(($k + 1) % $cols == 0 || $k == count($cats) - 1) : ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php else : ?>
<ul class="weblinks mod-list <?php echo $moduleclass_sfx; ?>">
<?php foreach ($list as $item) : ?>
<li>
<?php $link = $item->link; ?>
<?php
switch ($item->params->get('target', 3))
{
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2: if ($cols > 1) :
// Open in a popup window if ($k % $cols == 0) :
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" . echo '<div class="row row-fluid">';
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>'; endif;
break;
default: echo '<div class="col-' . 12 / $cols . '">';
// Open in parent window endif;
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
}
?>
<?php if ($params->get('description', 0)) : ?> if ($params->get('groupby_showtitle', 1)) :
<?php echo nl2br($item->description); ?> echo '<strong>' . htmlspecialchars($cat['title'], ENT_COMPAT, 'UTF-8') . '</strong>';
<?php endif; ?> endif;
<?php if ($params->get('hits', 0)) : ?> echo '<ul class="mod-list weblinks ' . $moduleclass_sfx . '">';
<?php echo '(' . $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS') . ')'; ?>
<?php endif; ?> foreach ($items as $item) :
</li> echo '<li><div class="d-flex flex-wrap">';
<?php endforeach; ?> echo '<div class="col flex-sm-grow-1">';
</ul>
<?php endif; ?> $link = $item->link;
switch ($item->params->get('target', 3)) :
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2:
// Open in a popup window
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
default:
// Open in parent window
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
endswitch;
echo '</div>';
echo $params->get('description', 0) ? '<div class="colvflex-sm-grow-1">' . nl2br($item->description) . '</div>' : '';
if ($params->get('hits', 0)) :
echo '<div class="col flex-sm-grow-1">';
echo '<span class="badge bg-info float-md-end">' . $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS') . '</span>';
echo '</div>';
endif;
echo '</li>';
endforeach;
echo '</ul>';
if ($cols > 1) :
echo '</div>';
if (($k + 1) % $cols == 0 || $k == count($cats) - 1) :
echo '</div>';
endif;
endif;
endforeach;
else :
echo '<ul class="mod-list weblinks ' . $moduleclass_sfx . '">';
foreach ($list as $item) :
echo '<li><div class="d-flex flex-wrap">';
echo '<div class="col flex-sm-grow-1">';
$link = $item->link;
switch ($item->params->get('target', 3)) :
case 1:
// Open in a new window
echo '<a href="' . $link . '" target="_blank" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
case 2:
// Open in a popup window
echo "<a href=\"#\" onclick=\"window.open('" . $link . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\">" .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
default:
// Open in parent window
echo '<a href="' . $link . '" rel="' . $params->get('follow', 'nofollow') . '">' .
htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '</a>';
break;
endswitch;
echo '</div>';
echo $params->get('description', 0) ? '<div class="col flex-sm-grow-1">' . nl2br($item->description) . '</div>' : '';
if ($params->get('hits', 0)) :
echo '<div class="col flex-sm-grow-1">';
echo '<span class="badge bg-info float-md-end">' . $item->hits . ' ' . Text::_('MOD_WEBLINKS_HITS') . '</span>';
echo '</div>';
endif;
echo '</li>';
endforeach;
echo '</ul>';
endif; ?>