Categories > TinyButStrong general >

NavBar Plug-in question

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: mgb
Date: 2007-12-12
Time: 19:17

NavBar Plug-in question

Hi all,
I have been quirt for too long so here is another question from me :)
I have the following (non working tbs/html code)
<tr>
  <td><a href="[nv.first;]">[nv.first]</a></td>
  <td>..</td>
  <td><a href="[nv.prev-navsize;endpoint;magnet=a;mtype=m+m]">back</a></td>
  <td>[nv;enpoint; when [nv.page-4]+-[nv.last]; block=td+td]..</td>
  <td><a href="[nv.page;block=td;navsize=3;navpos=centred">[nv.page]</a></td>
  <td>[nv.page;block=td;currpage]</td>
  <td>[nv;enpoint; when [nv.page+4]-+[nv.last]; block=td+td]..</td>
  <td><a href="[nv.next+navsize;endpoint;magnet=a;mtype=m+m]">forward</a></td>
  <td>..</td>
  <td><a href="[nv.last]">[nv.last]</a></td>
</tr>
I want the result  to look like this

1 .. back .. 3 4 5 .. forward .. 200
or
1 .. back .. 197 198 199 200
or
1 2 3 4 .. forward .. 200

Back and forward should jump 'navsize' or possibly a hardcoded
value ie. 3.

Hope anyone can help me with this. I know it might be stretching tbs
abilities :)
But maybe it can be handled with some clever onformat's?
Or should I try to rewrite the navigation plug-in all together?

Thanks
By: Skrol29
Date: 2007-12-13
Time: 00:03

Re: NavBar Plug-in question

Hello,

Here is an idea to try:
<tr>

  <td><a href="[nv.first]">[nv.first]</a></td>
  <td>..</td>

  <td><a href="[nv.curr;ope=add:-3;if [val]-+4;then '';magnet=td+td]">back</a></td>
  <td>..</td>

  <td><a href="[nv.page;block=td;navsize=3;navpos=centred]">[nv.page]</a></td>
  <td>[nv.page;block=td;currpage]</td>

  <td>..</td>
  <td><a href="[nv.curr;ope=add:+3;if [val]+-1964;then '';magnet=td+(td)]">forward</a></td>
 
  <td>..</td>
  <td><a href="[nv.last]">[nv.last]</a></td>

</tr>

But it probably won't work for the Forward link.
In this case, I suggest that you manage Back and Forward links using a PHP global variable. Display or not those links could be calculated in PHP.
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'=>'&laquo; Back','class'=>'link_button','url'=>'?page='.($_page-1));
else
  $nv_pages[] = array('page'=>0,'title'=>'&laquo; 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 &raquo;','class'=>'link_button','url'=>'?page='.($_page+1));
else
  $nv_pages[] = array('page'=>0,'title'=>'Forward &raquo;','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 :)
By: Skrol29
Date: 2007-12-16
Time: 13:04

Re: NavBar Plug-in question

Hi,

Yes it is possible:
$__tbs->MergeBlock('nv_top,nv_bot',$nv_pages);

You can also get the source of the block, merge it separately, and then merge the sub-content at several places in the template.