Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-01-2007, 03:06 AM
reddyink reddyink is offline
 
Join Date: Aug 2007
Posts: 236
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default php code in template for pagination

I have this chunck of code with for statements. I need to bring that in template because I want to display those those link near mod. Right now it is displaying at top of page like 1 2 3 4,.Links are working fine with currentpage no link. Code is working but it is displying on top since it is in php page all the records are in template.
I want to display the links near mod. the only way I can do is I have to bring this below code with for statements and links to display the current page and all other pagelinks.

Please can anyone can guide me, how can we display near section with if conditions.

$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ");
$currentpage= $i." ";
}else{
echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");
}
}

$totallimit=$totalrows % $limit;
if(($totalrows % $limit) != 0){
if($i == $page){
echo($i." ");
//$currentpage = $i;
}else{
echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");
}
}

I'll provide more details if needed
I really appreciate, if I get any help on this.
Thanks
Reply With Quote
  #2  
Old 12-01-2007, 06:30 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can not use PHP in templates, they are HTML only.

See the following on the basics on how to include data using plugins: Including External Files
Reply With Quote
  #3  
Old 12-01-2007, 07:22 PM
reddyink reddyink is offline
 
Join Date: Aug 2007
Posts: 236
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for reply marco.
I did exactly what you suggested. Now links are displaying on top of module, but I have one more problem. I am pretty sure Proffesional like you can help me with this.
1 2 links are displaying properly but when i click on 2nd page link - page is displaying with correct results and link is not going back to No 1 link.link still stays for No2. I cannot go to No1 page.
Actually with php page when I click on No2 link. Link should go away for No2 and link should come for No1.
Is there any way can we go back to include file to get the new link.
Can you please help me with if statement that can go back to include.php to change the links so I can switch between pages.

I really appreciate your help
Thanks
Reply With Quote
  #4  
Old 12-03-2007, 01:05 AM
reddyink reddyink is offline
 
Join Date: Aug 2007
Posts: 236
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I created a plugin to pointing to a new php file with pagination display code and added variable $included in template. Display is working fine with 1st page resullts and all other links. When I click on second page results are showing fine but hyperlink is still showing for 2nd page and no link for 1st page. I cannot go back to 1st page.
I am guessing, I have to write a If else code in my template or plugin. Can you please help me on that.

I think when page first loads it is working because Since $included variable has values that needs to display . For pagination links it is not going back to php page for following statement.
for($i = 1; $i <= $numofpages; $i++)

Thsi is the php code for pagination in my new php file-mypagination.php
$numofpages = $totalrows / $limit;

for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");
}
}

if(($totalrows % $limit) != 0){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"$PHP_SELF?page=$i\">$i</a> ");
}
}

plugin code:

ob_start();
include('C:/program files/EasyPHP 2.0b1/www/upload/vba_dyna_modules/mypagination.php');
$includedphp = ob_get_contents();
ob_end_clean();

Used $includedphp in template to display. Display is working fine with correct results on each page.
When i click on 2nd page, results are second page results but first page does not have link. the display stays the same. Actually 1st page should have link now not 2nd page.
How to go back to php page to get new display.

I have been working on this from 1 week. I'll really appreciate any kind of help.
Thanks
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:34 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04062 seconds
  • Memory Usage 2,191KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete