By: mgb
Date: 2007-12-13
Time: 11:55
|
Re: NavBar Plug-in question
Hi Skrol29,
My case was just to special to use NAVBAR so I solved it like this.
(php is still a bit mess, I will clean it up later)
php:
//get the galleries
if(include(config::objects.'/galleries.inc.php')) {
$gald = new gald($__db);
$imgs = $gald->get(1,1,null,$offset,$nv_thumbs_shown);
$total_gals = $gald->n_gals;
} else
$img = array();
if($_page > 1)
$nv_pages[] = array('page'=>0,'title'=>'« Back','class'=>'link_button','url'=>'?page='.($_page-1));
else
$nv_pages[] = array('page'=>0,'title'=>'« Back','class'=>'dead_button','url'=>'');
$pages = ceil($total_gals/$nv_thumbs_shown);
if($pages < 14) {
for($i=1;$i<=$pages;$i++)
if($i == $_page)
$nv_pages[] = array('page'=>0,'title'=>$i,'class'=>'curr_page','url'=>'?page='.$i);
else
$nv_pages[] = array('page'=>0,'title'=>$i,'class'=>'link','url'=>'?page='.$i);
} else {
if($_page > 6 && $_page < $pages-6) {
$nv_pages[] = array('page'=>0,'title'=>1,'class'=>'link','url'=>'?page=1');
$nv_pages[] = array('page'=>0,'title'=>2,'class'=>'link','url'=>'?page=2');
$nv_pages[] = array('page'=>0,'title'=>'...','class'=>'dots','url'=>'');
for($i=($_page-3);$i<($_page+4);$i++)
if($i == $_page)
$nv_pages[] = array('page'=>0,'title'=>$i,'class'=>'curr_page','url'=>'?page='.$i);
else
$nv_pages[] = array('page'=>0,'title'=>$i,'class'=>'link','url'=>'?page='.$i);
$nv_pages[] = array('page'=>0,'title'=>'...','class'=>'dots','url'=>'');
$nv_pages[] = array('page'=>0,'title'=>$pages-1,'class'=>'link','url'=>'?page='.$pages-1);
$nv_pages[] = array('page'=>0,'title'=>$pages,'class'=>'link','url'=>'?page='.$pages);
} elseif($_page < 7) {
for($i=1;$i<10;$i++)
if($i == $_page)
$nv_pages[] = array('page'=>0,'title'=>$i,'class'=>'curr_page','url'=>'?page='.$i);
else
$nv_pages[] = array('page'=>0,'title'=>$i,'class'=>'link','url'=>'?page='.$i);
$nv_pages[] = array('page'=>0,'title'=>'...','class'=>'dots','url'=>'');
$nv_pages[] = array('page'=>0,'title'=>$pages-1,'class'=>'link','url'=>'?page='.$pages-1);
$nv_pages[] = array('page'=>0,'title'=>$pages,'class'=>'link','url'=>'?page='.$pages);
} elseif ($_page > $pages-7) {
$nv_pages[] = array('page'=>0,'title'=>1,'class'=>'link','url'=>'?page=1');
$nv_pages[] = array('page'=>0,'title'=>2,'class'=>'link','url'=>'?page=2');
$nv_pages[] = array('page'=>0,'title'=>'...','class'=>'dots','url'=>'');
for($i=$pages-8;$i<$pages+1;$i++)
if($i == $_page)
$nv_pages[] = array('page'=>0,'title'=>$i,'class'=>'curr_page','url'=>'?page='.$i);
else
$nv_pages[] = array('page'=>0,'title'=>$i,'class'=>'link','url'=>'?page='.$i);
}
}
if($_page < $pages)
$nv_pages[] = array('page'=>0,'title'=>'Forward »','class'=>'link_button','url'=>'?page='.($_page+1));
else
$nv_pages[] = array('page'=>0,'title'=>'Forward »','class'=>'dead_button','url'=>'');
$__tbs->MergeBlock('nv',$nv_pages);
|
and the tbs:
<table class="page_no">
<tr>
<td class="[nv.class;when [nv.class]~='/link.*/';block=td]"><a href="[nv.url]">[nv.title;htmlconv=esc]</a></td>
<td class="[nv.class;default;block=td]"><div>[nv.title;htmlconv=esc]</div></td>
</tr>
</table>
|
Then there is a lot of stylesheets to make it very very very beautiful :)
This works fine, and even though its a quite big chunk of code with some repeating elements I am quite satisfied. (as mentioned I will clean it up later)
My new problem is I want to have this both in the bottom and top of my page.
is there a way to not have tbs do the same twice?
what I want to avoid is:
$__tbs->MergeBlock('nv_top',$nv_pages);
$__tbs->MergeBlock('nv_bot',$nv_pages);
|
and just have it done once for both ends. Is this possible?
Btw Skroll29, it seems to me that the majority of your support has come to me from 24-03 :)
Am I wrong in my assumption that you are from France?
Or are you just a genuine night owl :)
|