Categories > TinyButStrong general >

prev & next page display when there's no result

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: jorge
Date: 2004-02-17
Time: 01:16

prev & next page display when there's no result

Hi,

I have a small problem.

When my SQL request returns No results, I still have "previous page" and "next page" links active.

<td width="178" align="center" valign="middle" bgcolor="#9C30FF">
<a href="[sys.script_name]?PageNum=[nv.next;endpoint;friend=td]
[var.motclef;if [val]='';then ''; else '&motclef=[val]';noerr]
[var.ch_pseudo;if [val]='';then ''; else '&ch_pseudo=[val]';noerr]
    "><font color="#FFFFFF">Next Page &gt;&gt;</font></a></td>

Where could it come from?

I've tryed with your exemple from "display by page" from your exemple site...where I removed all data, and get same result.
By: Skrol29
Date: 2004-02-17
Time: 13:32

Re: prev & next page display when there's no result

Hi,

Yes that's a bug.
To fix it, you can wait for the next patch (in few days) or make the change at line #1897: it should be '==' instead of '==='.
By: jorge
Date: 2004-02-17
Time: 23:42

Re: prev & next page display when there's no result

Are you talking about line 1894?
if ($CurrNav[$Loc->SubName]===$CurrNav['bound']) {

I've tried with
if ($CurrNav[$Loc->SubName]==$CurrNav['bound']) {

and still have the problem...
By: Skrol29
Date: 2004-02-18
Time: 17:53

Re: prev & next page display when there's no result

Sorry for my previous post
That's line 1896 (TBS 1.93), replace:
if ($CurrNav[$x]===$CurrNav['bound']) {
with:
if ($CurrNav[$x]==$CurrNav['bound']) {

It works for me.
By: jorge
Date: 2004-02-19
Time: 16:39

Re: prev & next page display when there's no result

It effectly works on the example I took from your site...but not on mine... :(

And I use same syntax:
<a href="[sys.script_name]?PageNum=[nv.next;endpoint;friend=td]
<a href="[sys.script_name]?PageNum=[nv.next;endpoint;friend2=a]

well whatever I use...stil get the problem...gloups


By the way, [var.reccnt] tells there's one record..and that's not true, as SQL returns nothing.
By: jorge
Date: 2004-02-19
Time: 16:44

Re: prev & next page display when there's no result

The only difference I see is that on
<td width="178" align="center" valign="middle" bgcolor="#9C30FF">
<a href="[sys.script_name]?PageNum=[nv.next;endpoint;friend=td]
[var.motclef;if [val]='';then ''; else '&motclef=[val]';noerr]
[var.ch_pseudo;if [val]='';then ''; else '&ch_pseudo=[val]';noerr]
"><font color="#FFFFFF">Next Page &gt;&gt;</font></a></td>

$motclef or $ch_pseudo are defined values

perhaps it could help?

grrr...I've tried  to remove every extra value and just keeping
<a href="[sys.script_name]?PageNum=[nv.next;endpoint;friend=td]"><font color="#FFFFFF">Next Page &gt;&gt;</font></a>

still get the problem... :(
By: Jorge
Date: 2004-02-19
Time: 17:05

Seems the problem comes from sub templates

Well well well..

I suspect the problem comes from when I call a external template before rendering the maseter template.

I'm using
$TBS_resultat->Render = TBS_OUTPUT ;

$TBS_resultat->Show() ;
at the end of my external template as you told to do on manual, but I'm not even able to write a [var.php_version] !

Everything works fine when I don't use sub-templates...
doesn't work if I use sub Templates!

Going to do some more tests...or try to rewrite everithing without sub templates... :( :(
By: Skrol29
Date: 2004-02-19
Time: 18:49

Re: Seems the problem comes from sub templates

Salut Jorge,

If you cant' go througth, you can send me your code.
I'm ready to publish the bug fix (TBS version 1.94) but I'd like to be sure that it is all ok.
By: Jorge
Date: 2004-02-19
Time: 19:24

Re: Seems the problem comes from sub templates

salut Skroll,

Ci joint mon code:

Nothing special with main template

main.php
include_once("classes/tbs.php") ;
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate("main.inc.htm");
$TBS->Show() ;
main.inc.htm
<td valign="top">
    [tbs_include.onshow;script=templates/result.inc.php;getob]</td>

Then my sub_template:

result.inc.php:

include_once("tbs.php") ;

//Valeurs utilisées pour l'affichage parge par page
//Valeur par défaut
if (!isset($_GET)) $_GET=&$HTTP_GET_VARS ;
if (isset($_GET['PageNum'])) {
  $PageNum = $_GET['PageNum'] ;
} else {
    $PageNum = 1 ;
}

//Valeur par défaut
if (isset($_GET['RecCnt'])) {
  $RecCnt = intval($_GET['RecCnt']) ;
} else {
    $RecCnt = -1 ;
}

$PageSize = 7 ;  // Nombre de résultats par pages
//-----------------------------

$TBS_resultat = new clsTinyButStrong ;

$TBS_resultat->LoadTemplate('templates/result.inc.php.htm) ;


// ##### DEBUT ######### MON CODE PHP VA ICI ###############
// Fonctions utilisés:

function antislash($FieldName,&$CurrVal) {
  $CurrVal=stripslashes($CurrVal) ;
}


//------  Connection SQL  ----------------------------------
require("connect_mysql.inc.php"); // Ouverture BD



$query = "select * from database";

$RecCnt = $TBS_resultat->MergeBlock('blk1',$cnx_id,$query,$PageSize,$PageNum,$RecCnt) ;
$TBS_resultat->MergeNavigationBar('nv',7,$PageNum,$RecCnt,$PageSize) ;

mysql_close($cnx_id) ; // Déconnection BD
// ###### FIN ##############################################


$TBS_resultat->Render = TBS_OUTPUT ;

$TBS_resultat->Show() ;
?>

result.inc.php.htm


<td height="295" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0" align=center>
  <!--DWLayoutTable-->
  <tr>
    <td width="740" height="17" valign="top" class="fond-resultat">R&eacute;sultats
      de votre recherche</td>
  </tr>
  <tr>
    <td height="20" align="center" valign="top" bgcolor="#C6C3C6" class="table-cadre-top-down-gris"><p>[tbs_check;if [blk1.#]=500;then 'Plus de <strong>500 annonces</strong> correspondent &agrave; votre
        recherche.<br>
  Vous pouvez affiner vos r&eacute;sultats en sp&eacute;cifiant <strong>plus
            de crit&egrave;res</strong> de recherche.';else
            '[blk1.#] annonce(s) correspond(ent) &agrave; votre
            recherche.<br>
            Vous pouvez obtenir <strong>plus de r&eacute;sultats</strong> en
            sp&eacute;cifiants <strong>moins
      de crit&egrave;res</strong>        de recherche.        ';htmlconv=no]</p>      </td>
  </tr>
</table>
<br>
<table width="612" align="center" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="308" height=19 align="left" valign="middle"><meu1><a href="[sys.script_name]
    ?PageNum=[nv.prev;endpoint;friend=meu1]
    [var.motclef;if [val]='';then ''; else '&motclef=[val]';noerr]
    [var.ch_pseudo;if [val]='';then ''; else '&ch_pseudo=[val]';noerr]
    [var.sexe_recherche;if [val]='';then ''; else '&sexe_recherche=[val]';noerr]
    [var.tranche_age;if [val]='';then ''; else '&tranche_age=[val]';noerr]
    [var.etat_civil;if [val]='';then ''; else '&etat_civil=[val]';noerr]
    [var.region;if [val]='';then ''; else '&region=[val]';noerr]
    [var.type_rencontre1;if [val]='';then ''; else '&type_rencontre1=[val]';noerr]
    [var.type_rencontre2;if [val]='';then ''; else '&type_rencontre2=[val]';noerr]
    [var.type_rencontre3;if [val]='';then ''; else '&type_rencontre3=[val]';noerr]
    [var.photo;if [val]='';then ''; else '&photo=[val]';noerr]"><img src="menus_images/icon_nav_previous.gif" width="7" height="12" border="0">&nbsp;<font color="#999999">Annonce(s)
      pr&eacute;c&eacute;dente(s)</font></a></meu1></td>
    <td width="297" align="right" valign="middle"><meu1><a href="[sys.script_name]?PageNum=[nv.next;endpoint;friend=meu1][var.motclef;if [val]='';then ''; else '&motclef=[val]';noerr]
    [var.ch_pseudo;if [val]='';then ''; else '&ch_pseudo=[val]';noerr]
    [var.sexe_recherche;if [val]='';then ''; else '&sexe_recherche=[val]';noerr]
    [var.tranche_age;if [val]='';then ''; else '&tranche_age=[val]';noerr]
    [var.etat_civil;if [val]='';then ''; else '&etat_civil=[val]';noerr]
    [var.region;if [val]='';then ''; else '&region=[val]';noerr]
    [var.type_rencontre1;if [val]='';then ''; else '&type_rencontre1=[val]';noerr]
    [var.type_rencontre2;if [val]='';then ''; else '&type_rencontre2=[val]';noerr]
    [var.type_rencontre3;if [val]='';then ''; else '&type_rencontre3=[val]';noerr]
    [var.photo;if [val]='';then ''; else '&photo=[val]';noerr]
    "><font color="#999999">Annonce(s) suivante(s)&nbsp;</font><img src="menus_images/icon_nav_next.gif" width="7" height="12" border="0"></a></meu1></td>
  </tr>
</table>
<form name="formulaire1" method="post" action="i_liste_annonce.php">
[blk1;block=begin]
<TABLE cellSpacing=5 cellPadding=0 width=618 border=0 align=center class="table-cadre-mauve">
  <!--DWLayoutTable-->
  <TBODY>
  <TR>
    <TD width="115" rowspan="3" valign="top">
      <table width="115" border="0" cellpadding="0" cellspacing="0">
              <!--DWLayoutTable-->
              <tr>
                <td width="102" height="150">
                <img src="http://www.mysite.com/fr/[blk1.profil_3_annonce_photo_petite;ifempty = [tbs_check;if [blk1.aff_sexe_je_suis_base]=Homme;then 'images/homme.jpg';else 'images/femme.jpg']]" width="100" border="1" alt="Cliquez ici pour consulter l'annonce de [blk1.profil_1_base_pseudo;block=row]">
                 </td>
                <td width="13"></td>
              </tr>
            </table>
    </TD>
    <TD width="262" height="10" valign="top"><strong>[blk1.profil_1_base_pseudo;block=row]</strong></TD>
    <TD width="330" align="right" valign="top">[blk1.aff_pays_liste;block=row], [blk1.aff_region_liste;block=row], [blk1.profil_0_coordonnees_adresse_dep;block=row]</TD>
    <td width="1"></td>
  </TR>
  <TR>
    <TD height="30" colspan="2" valign="top" class="annonce">[blk1.aff_sexe_je_suis_base] de [blk1.profil_1_base_age;block=row] ans, recherche [blk1.aff_sexe_je_cherche_base;block=row]
      pour [blk1.aff_type_rencontre_base;block=row].<br>
      <br>
[blk1.profil_3_annonce_texte;max=80;onformat=antislash]</TD>
    <td></td>
  </TR>
  <TR>
    <TD colspan="2" rowspan="2" valign="top">
      <ul class="tnav">
            <li><a href="e"><img src="menus_images/icon_apercu.gif" width="15" height="12" border="0">&nbsp;voir son annonce</a></li>
            <li><a href="e"><img src="menus_images/icon_favoris.gif" width="15" height="12" border="0">&nbsp;ajouter &agrave; mes favoris</a></li>
            <li><a href="d"><img src="menus_images/icon_envoyer_message.gif" width="15" height="10" border="0">&nbsp;lui &eacute;crire</a></li>
      </ul>
    </TD>
    <td height="20"></td>
  </TR>
  </TBODY>
</TABLE>
<br>
[blk1;block=end]

<table width="100%" cellpadding="0" cellspacing="0" align="center" class="table-cadre-alerte-mauve">
  <tr>
    <TD height=42 colspan="2" valign="middle" align=center>
      [blk1;block=table;nodata] Aucune annonce ne r&eacute;pond &agrave; vos
      crit&egrave;res
      de recherche.</TD>
  </tr>
</table>
</form>
<table width="612" cellpadding="0" cellspacing="0" align="center">
  <!--DWLayoutTable-->
  <tr>
    <td width="178" height=19 align="left" valign="middle"><meu1><a href="[sys.script_name]
    ?PageNum=[nv.prev;endpoint;friend=meu1]
    [var.motclef;if [val]='';then ''; else '&motclef=[val]';noerr]
    [var.ch_pseudo;if [val]='';then ''; else '&ch_pseudo=[val]';noerr]
    [var.sexe_recherche;if [val]='';then ''; else '&sexe_recherche=[val]';noerr]
    [var.tranche_age;if [val]='';then ''; else '&tranche_age=[val]';noerr]
    [var.etat_civil;if [val]='';then ''; else '&etat_civil=[val]';noerr]
    [var.region;if [val]='';then ''; else '&region=[val]';noerr]
    [var.type_rencontre1;if [val]='';then ''; else '&type_rencontre1=[val]';noerr]
    [var.type_rencontre2;if [val]='';then ''; else '&type_rencontre2=[val]';noerr]
    [var.type_rencontre3;if [val]='';then ''; else '&type_rencontre3=[val]';noerr]
    [var.photo;if [val]='';then ''; else '&photo=[val]';noerr]"><img src="menus_images/icon_nav_previous.gif" width="7" height="12" border="0">&nbsp;<font color="#999999">Annonce(s)
      pr&eacute;c&eacute;dente(s)</font></a></meu1></td>
    <td width="245" align="center" valign="top"><font color="#9C9A9C">Page [nv.curr] sur [nv.last]</font></td>
    <td width="181" align="right" valign="middle"><meu1><a href="[sys.script_name]
    ?PageNum=[nv.next;endpoint;friend=meu1]
    [var.motclef;if [val]='';then ''; else '&motclef=[val]';noerr]
    [var.ch_pseudo;if [val]='';then ''; else '&ch_pseudo=[val]';noerr]
    [var.sexe_recherche;if [val]='';then ''; else '&sexe_recherche=[val]';noerr]
    [var.tranche_age;if [val]='';then ''; else '&tranche_age=[val]';noerr]
    [var.etat_civil;if [val]='';then ''; else '&etat_civil=[val]';noerr]
    [var.region;if [val]='';then ''; else '&region=[val]';noerr]
    [var.type_rencontre1;if [val]='';then ''; else '&type_rencontre1=[val]';noerr]
    [var.type_rencontre2;if [val]='';then ''; else '&type_rencontre2=[val]';noerr]
    [var.type_rencontre3;if [val]='';then ''; else '&type_rencontre3=[val]';noerr]
    [var.photo;if [val]='';then ''; else '&photo=[val]';noerr]
    "><font color="#999999">Annonce(s) suivante(s)&nbsp;</font><img src="menus_images/icon_nav_next.gif" width="7" height="12" border="0"></a></meu1></td>
  </tr>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align=center>
  <tr>
    <td width="618" height="19" valign="top" align="center">Vous pouvez &eacute;galement
      &eacute;ffectuer une recherche par <a href="recherche-par-pseudo.php">nom
       d'utilisateur / pseudo</a> ou par <a href="recherche-par-mot-clef.php">mot
       clef</a></td>
  </tr>
</table>
</td>

Well i've removed some few things so don't be astonished about some variables that are not definde on this code.

it works fine if a directly call
result.inc.php
doesnt work if I run it from main template

Jorge
By: Skrol29
Date: 2004-02-20
Time: 14:51

Re: Seems the problem comes from sub templates

My remarks about your sub-template

- function antislash() will probably be ignored or something because since 'result.inc.php' is started from a parameter 'script' then it is executed in a function environment and not in a global environement.

- in 'result.inc.php.htm', the block blk1 is defined several times with self-embedded definitions. This is not good.
For example, you have [blk1;block=begin]/[blk1;block=end] plus [blk1.profil_1_base_pseudo;block=row] inside, plus [blk1.aff_pays_liste;block=row] on the same row ....

By: Pirjo Posio
Date: 2004-02-20
Time: 21:20

Re: Seems the problem comes from sub templates

Hi Skrol29,

This "since 'result.inc.php' is started from a parameter 'script' then it is executed in a function environment and not in a global environement" should be stated clearly in the manual.
- Pirjo
By: Jorge
Date: 2004-02-23
Time: 01:31

Re: Seems the problem comes from sub templates

function antislash works perfectly... :)
Perhaps I could improve it, but didn't understood what you mean with global environnment (example?)

in result.inc.php.htm, I 'm talking about the same bll1 for all data,
you mean I don't have to provide ";block=row"  detail everywhere?

You said my code is not goog, thnks for the advice, but I don't see clear information on manual and you don't provide me with right solution.... :(

Could you help me some more about it?

(
Skroll:

just a remark about the manual, I'm shure everybody would enjoy if you could provide some more examples ofr each function.
I know this class involves a lot of free work from you, but as it's also a great class, it be sad if no body could use it, because development is not clear)
Actualy I know TBS is great, but I take much more time to test it and understand how it works without examples, then doing all the code by myself with small dedicated classes.
But as i know that inteligent way to develop is to seperate PHP code and template...well I 'm trying to capitalise my work into TBS)

TBS still a really great work from you, but with more examples, you should see more people using it
By: Jorge
Date: 2004-02-23
Time: 02:18

Re: Seems the problem comes from sub templates

Hi Skroll

I missunderstood the block definition

I san "block=row" into an example...and thaught it was someting like PHP row...

So now I understood that on my page, block is the tag from wich i want the block to start and stops

going to re read several times the manual...

about just one point, I saw that we 're using french and english variables names into TBS.. are they both working? (depending of fr or us release TBS class downloaded?

Because, for my part I sometimes saw examples with both labguage variables, i ofen get confused...
By: Skrol29
Date: 2004-02-23
Time: 10:18

Re: Seems the problem comes from sub templates

>in result.inc.php.htm, I 'm talking about the same bll1
>for all data, you mean I don't have to provide ";block=row"
>detail everywhere?

No you don't.
To define a block is to define its bounds. You can define bounds using the explicite syntax (2 tags, 1 with block=begin, 1 with block=end) OR the relative syntax. For the relative syntaxe, you just have to put the parameter block=... into a TBS filed. Only one is enought because it defines the bounds. It doesn't have to be the first tag of the block, it can be any.

Here is an example of what your form template could be:
(note that there are two section in the block, 1 normal section and 1 nodta section)
<form name="formulaire1" method="post" action="i_liste_annonce.php">
<TABLE cellSpacing=5 cellPadding=0 width=618 border=0 align=center class="table-cadre-mauve">
  <!--DWLayoutTable-->
  <TBODY>
  <TR>
    <TD width="115" rowspan="3" valign="top">
  <table width="115" border="0" cellpadding="0" cellspacing="0">
              <!--DWLayoutTable-->
              <tr>
                <td width="102" height="150">
    <img src="http://www.mysite.com/fr/[blk1.profil_3_annonce_photo_petite;ifempty = [tbs_check;if [blk1.aff_sexe_je_suis_base]=Homme;then 'images/homme.jpg';else 'images/femme.jpg']]" width="100" border="1" alt="Cliquez ici pour consulter l'annonce de [blk1.profil_1_base_pseudo;block=row]">
</td>
                <td width="13"></td>
              </tr>
          </table>
    </TD>
    <TD width="262" height="10" valign="top"><strong>[blk1.profil_1_base_pseudo]</strong></TD>
    <TD width="330" align="right" valign="top">[blk1.aff_pays_liste;block=table],
      [blk1.aff_region_liste], [blk1.profil_0_coordonnees_adresse_dep]</TD>
    <td width="1"></td>
  </TR>
  <TR>
    <TD height="30" colspan="2" valign="top" class="annonce">[blk1.aff_sexe_je_suis_base]
      de [blk1.profil_1_base_age] ans, recherche [blk1.aff_sexe_je_cherche_base]
      pour [blk1.aff_type_rencontre_base].<br>
      <br>
[blk1.profil_3_annonce_texte;max=80;onformat=antislash]</TD>
    <td></td>
  </TR>
  <TR>
    <TD colspan="2" rowspan="2" valign="top">
  <ul class="tnav">
            <li><a href="e"><img src="menus_images/icon_apercu.gif" width="15" height="12" border="0">&nbsp;voir son annonce</a></li>
        <li><a href="e"><img src="menus_images/icon_favoris.gif" width="15" height="12" border="0">&nbsp;ajouter &agrave; mes favoris</a></li>
        <li><a href="d"><img src="menus_images/icon_envoyer_message.gif" width="15" height="10" border="0">&nbsp;lui &eacute;crire</a></li>
      </ul>
    </TD>
    <td height="20"></td>
  </TR>
  </TBODY>
</TABLE>
<br>
<table width="100%" cellpadding="0" cellspacing="0" align="center" class="table-cadre-alerte-mauve">
  <tr>
    <TD height=42 colspan="2" valign="middle" align=center>
      [blk1;block=table;nodata] Aucune annonce ne r&eacute;pond &agrave; vos
      crit&egrave;res
      de recherche.</TD>
  </tr>
</table>
</form>
By: Skrol29
Date: 2004-02-23
Time: 10:24

Re: Seems the problem comes from sub templates

>about just one point, I saw that we 're using french and
> english variables names into TBS..
> are they both working? (depending of fr or us release
> TBS class downloaded?

I think you are talking about the examples, because the TBS code source is the same for both english and french version.
Yes they are both working. I've translated the examples set and sometime code also because I know users read the example codes.

>TBS still a really great work from you, but with
> more examples, you should see more people using it

I agree, but this is lot of work. Don't forget that the forum is a good example too. I'm planning to give some full apllications as extra examples.