Искать  
 
   
 
Предыдущая и следующая фотография в галерее
Отправлено: 30 Август 2009 10:28 P.M.   [ Игнорировать ]
Администратор
Avatar
RankRankRankRank
Всего сообщений:  1423
Зарегистрирован  2007-12-27

Кому, интересно. Есть способ вывода предыдущей и следующей фотографии в галерее.

Способ, как признает сам автор, не самый лучший но работает.

Если у кого есть свои соображения по этому поводу, отпишитесь.

Линк: http://expressionengine.com/forums/viewreply/310502/

Ok, well for now I’m settling for a hack (in my opinion, anyway…). I’m using a mix of PHP and embedding to get it done.

First, I enabled PHP on output for my photo item template, then I grab the entry_id of the previous and next photos via PHP:

{exp:gallery:next_entry gallery="{gallery_name}"}
    <?php $next_entry 
"{entry_id}"?>
{
/exp:gallery:next_entry}

{exp
:gallery:prev_entry gallery="{gallery_name}"}
    <?php $prev_entry 
"{entry_id}"?>
{
/exp:gallery:prev_entry} 

…then I called a separate template via {embed}, sending the PHP variables to the template:

{embed="photos/nav" next_entry="<?php echo $next_entry; ?>" prev_entry="<?php echo $prev_entry; ?>"

Then I created a new template, “nav,” in the “photos” group, with code to individually load the next and previous photos:

{!-- template variables --}
{assign_variable
:gallery_name="default"}
{assign_variable
:gallery_id="1"}

<ul>
    
{exp:gallery:entries gallery="{gallery_name}" entry_id="{embed:prev_entry}"}
        
<li><a href="{id_path=photos/album}"><img src="/images/phpthumb/phpThumb.php?src={image_url}&w=100&h=100&zc=1" title="previous entry" alt="{title}" width="100" height="100" /><br />« prev</a></li>
    
{/exp:gallery:entries}

    {exp
:gallery:entries gallery="{gallery_name}" entry_id="{embed:next_entry}"}
        
<li><a href="{id_path=photos/album}"><img src="/images/phpthumb/phpThumb.php?src={image_url}&w=100&h=100&zc=1" title="next entry" alt="{title}" width="100" height="100" /><br />next »</a></li>
    
{/exp:gallery:entries}
</ul

So far it’s working, but I have to admit I don’t like the idea of calling another embed and two more entry tags—for performance reasons, mainly. I don’t know if there are any other drawbacks or if I should feel comfortable using this method. Any feedback would certainly be welcome!

 Подпись 

ExpressionEngine - SEO-ориентированный движок

Профиль