there is nothing to do for those who know pike alot :)
And since the topic of this list/conference is development _of_pike_, not development _in_pike_ (for applications such as Roxen WebServer), I must ask you to post such questions elsewhere; the roxen list would probably be your best bet (roxen@roxen.com).
(And when doing so, I would recommend a but more emphasis on what you want help to achieve; it was not obvious to me, anyway.)
/ Johan Sundström (ska bli kalif i stället för kalifen)
Previous text:
2002-10-07 09:44: Subject: maybe yes maybe not (jsut look on it) maybe can show me the way :)
maybe someone can read this if have some little time there is nothing to do for those who know pike alot :)
this is navigation trought pages as much records emited from sql as the pike draws little buttons to navigate trought pages so I want to put this in Roxen module to use it in any virtual server without pike script to prevent users to access pike scripts and crash my server :)
for example it should look like this (I have tryed to make this module for Roxen but I cant do it something I do wrong, maybe somebody can help me. how exactly I need to write module for roxen to get result of this)
<pagelist page="1" count="100" link="index.rxml?bla1=1&bla2=2" bgcolor="black" fgcolor="white" onbgcolor="white" onfgcolor="black"/> I have added to code file://taken from tag attribute// where should apear value from tag atributes like page="1" count="100" bgcolor="black" and so on
also must restrict to use symbols from tag attribute values: ' " > < ` ? ! = - ; : (like bgcolor=";;,.":!#:!" strip off these bad symbols)
<?pike int c; int imag; int inPage; int pages; int Page; int pages10; Page=(int)form.page; // not form but value from tag page="1" // inPage=(int)1; imag=(int)var.pcount; // not var but value from tag count="100" // pages=(int)(imag/inPage); pages10=(int)(Page-1)/10; if((imag%inPage)!=0) pages++; if(pages10-1>=0) { write (rxml("<gtext magic notrans bgcolor='//taken from tag attribute//' magic magic-fgcolor='//taken from tag attribute//' magic-bgcolor='//taken from tag attribute//' font='pike builtin' border='0' href=\"//taken from tag attribute//&page="+(string)(pages10*10-9)+"\"> prev </gtext> ")); } if(Page-1>=1) { write (rxml(" <gtext magic notrans bgcolor='//taken from tag attribute//' magic magic-fgcolor='//taken from tag attribute//' magic-bgcolor='//taken from tag attribute//' font='pike builtin' border='0' href=\"//taken from tag attribute//&page="+(string)(Page-1)+"\"> << </gtext> ")); } for(c=(pages10*10+1);(c<=(pages10+1)*10)&&(c<=pages);c++) { write (rxml("<if match=\""+(string)(c)+" == &var.page;\"><gtext notrans fgcolor='//taken from tag attribute//' bgcolor='//taken from tag attribute//' font='pike builtin' border='0' href=\"//taken from tag attribute//&page="+(string)(c)+"\">"+(string)(c)+" </gtext></if><else><gtext notrans bgcolor='//taken from tag attribute//' magic magic-fgcolor='//taken from tag attribute//' magic-bgcolor='//taken from tag attribute//' font='pike builtin' border='0' href=\"//taken from tag attribute//&page="+(string)(c)+"\">"+(string)(c)+" </gtext></else> ")); } if((Page+1)*1<=pages) { write (rxml("<gtext magic notrans bgcolor='//taken from tag attribute//' magic magic-fgcolor='//taken from tag attribute//' magic-bgcolor='//taken from tag attribute//' font='pike builtin' border='0' href=\"//taken from tag attribute//&page="+(string)(Page+1)+"\"> >> </gtext>")); } if((pages10+1)*10<=pages) { write (rxml("<gtext magic notrans bgcolor='//taken from tag attribute//' magic magic-fgcolor='//taken from tag attribute//' magic-bgcolor='//taken from tag attribute//' font='pike builtin' border='0' href=\"//taken from tag attribute//&page="+(string)(pages10*10+11)+"\"> next </gtext>")); } ?>
so is it possible to add this to module so I can add this module to some virtual server and use it in html page to get this out on page
of course at first ther is need to count records from sql and calclulate them this is too need to be a differend module like
<get_rcount from='sample,ads where sample.adsid=ads.id and ads.kat1="&form.kat1:mysql;" and ads.kat2="&form.kat2:mysql;" '>
<?pike int cols=0; string st; float size=(float)rxml("<emit source=sql query='select count(*) as \"adm\" // value taken from tag get_rcount // '>&sql.adm;</emit>"); if ((int)var.page >ceil((size / 18))) var.page=(int)ceil((size / 18)); if ( (int)var.page < 1) var.page = 1; var.skiprows=((int)var.page -1)*18; var.pcount=(string)(int)ceil((float)(size / 18)); var.adsize=((string)(int)size); ?>
later this is used by this next tag pagelist
and then results used and added to this tag
<pagelist page="&form.page;" count="&var.record_count;" link="index.rxml?bla1=1&bla2=2" bgcolor="black" fgcolor="white" onbgcolor="white" onfgcolor="black"/>
and in page it should look like this
<set variable="var.sqlz" value="&var.sql;"/> <if variable="form.page"> <set variable="var.page" value="&form.page;"/> </if> <else> <set variable="var.page" value="1"/> </else> <set variable="var.skiprows" value=""/> <set variable="var.last" value=""/> <get_rcount from='sample,ads where sample.adsid=ads.id and ads.kat1="&form.kat1:mysql;" and ads.kat2="&form.kat2:mysql;" '>
<emit source="sql" query='select * from 'sample,ads where sample.adsid=ads.id and ads.kat1="&form.kat1:mysql;" and ads.kat2="&form.kat2:mysql;" limit &var.skiprows;,18'> blabla data maka hdjad
</emit>
<pagelist page="&form.page;" count="&var.record_count;" link="index.rxml?bla1=1&bla2=2" bgcolor="black" fgcolor="white" onbgcolor="white" onfgcolor="black"/>
/ Brevbäraren