Results 1 to 4 of 4

Thread: {next_prev} tag for blog_index.html template.

  1. #1
    Join Date
    Aug 2004
    Location
    Săo Paulo - Brasil.
    Age
    39
    Posts
    151

    Default {next_prev} tag for blog_index.html template.

    Olá.

    Tested at SVN. Rev. 2531.

    At blog_display.inc.php i just modified the function "disply_blog_index".

    PHP Code:
    function disply_blog_index(){
            global 
    $conn$config$lang;
            require_once(
    $config['basepath'] . '/include/misc.inc.php');
            
    //Load the Core Template
            
    require_once($config['basepath'] . '/include/class/template/core.inc.php');
            
    $misc = new misc();
            
    $page = new page_user();
            require_once(
    $config['basepath'] . '/include/blog_functions.inc.php');
            
    $blog_functions = new blog_functions();
            
    // Make Sure we passed the PageID
            
    $display '';
            
    //TODO Make limit configurable
            
    $sql "SELECT blogmain_full,blogmain_id FROM " $config['table_prefix'] . "blogmain WHERE blogmain_published = 1";
            
    //ORDER BY blogmain_date DESC LIMIT 5;
            
    $recordSet $conn->Execute($sql);
            if (
    $recordSet === false) {
                
    $misc->log_error($sql);
            }
            
            
    $num_rows $recordSet->RecordCount();
            if (!isset(
    $_GET['cur_page'])) {
            
    $_GET['cur_page'] = 0;
            }
            
            
    $limit_str $_GET['cur_page'] * $config['listings_per_page'];
            
    $recordSet $conn->SelectLimit($sql$config['listings_per_page'], $limit_str);
            if (
    $recordSet === false) {
            
    $misc->log_error($sql);
            }        

            
    $page->load_page($config['template_path'] . '/blog_index.html');
            
    $blog_entry_template '';
            while (!
    $recordSet->EOF) {
                
    $blog_entry_template .= $page->get_template_section('blog_entry_block');
                
    //Get Fields
                
    $id $recordSet->fields['blogmain_id'];
                
    $full html_entity_decode($misc->make_db_unsafe($recordSet->fields['blogmain_full']), ENT_NOQUOTES$config['charset']);
                
    //Start Replacing Tags
                
    $blog_title $blog_functions->get_blog_title($id);
                
    $blog_entry_template $page->parse_template_section($blog_entry_template'blog_title'$blog_title);
                
    $summary_endpos strpos($full,'<hr');
                if(
    $summary_endpos!==FALSE){
                    
    $summary=substr($full,0,$summary_endpos);
                }else{
                    
    $summary=$full;
                }
                
    $blog_entry_template $page->parse_template_section($blog_entry_template'blog_summary'$summary);
                
    $blog_author=$blog_functions->get_blog_author($id);
                
    $blog_entry_template $page->parse_template_section($blog_entry_template'blog_author'$blog_author);
                
    $blog_comment_count=$blog_functions->get_blog_comment_count($id);
                
    $blog_entry_template $page->parse_template_section($blog_entry_template'blog_comment_count'$blog_comment_count);
                
    $blog_date_posted=$blog_functions->get_blog_date($id);
                
    $blog_entry_template $page->parse_template_section($blog_entry_template'blog_date_posted'$blog_date_posted);
                if (
    $config['url_style'] == '1') {
                    
    $article_url 'index.php?action=blog_view_article&amp;ArticleID=' $id;
                }else {
                    
    $url_title str_replace("/"""$blog_title);
                    
    $url_title strtolower(str_replace(" "$config['seo_url_seperator'], $url_title));
                    
    $article_url 'article-' urlencode($url_title) . '-' $id '.html';
                }
                
    $blog_entry_template $page->parse_template_section($blog_entry_template'blog_link_article'$article_url);

                
    $recordSet->MoveNext();
            }
            
    $page->replace_template_section('blog_entry_block'$blog_entry_template);
            
            
    $next_prev $misc->next_prev($num_rows$_GET['cur_page'], "",'blog',TRUE);
            
    $page->replace_tag('next_prev'$next_prev);
            
            
    $page->replace_permission_tags();
            
    $display .= $page->return_page();
            return 
    $display;
        } 
    And the blog_index.html Just insert {next_prev} tag.

    HTML Code:
    {next_prev}
    {blog_entry_block}
    <div class="blog_entry">
    	<div class="blog_date">{blog_date_posted}</div>
    	<div class="blog_title">{blog_title}</div>
    
    	<div class="blog_summary">{blog_summary}</div>
    
    	<div class="blog_story_link_line"><a href="{blog_link_article}" class="blog_story_link" title="{blog_title}">{lang_blog_read_story} &gt;&gt;</a></div>
    	<div class="blog_entry_footer">
    		<div class="blog_byline">{lang_blog_post_by} {blog_author}</div> 	<div class="blog_comments">({blog_comment_count}) {lang_blog_comments}</div>
    	</div>
    </div>
    {/blog_entry_block}
    Now is displayed based at listings_per_page configuration.

    [ ]´s

    ...a blind padawan...

  2. #2
    Join Date
    Apr 2006
    Posts
    14

    Default Re: {next_prev} tag for blog_index.html template.

    Very helpful. Thanks!

  3. #3
    Join Date
    Aug 2009
    Location
    Phoenix AZ
    Posts
    6

    Default Re: {next_prev} tag for blog_index.html template.

    Thanks for this. Has anyone figured out a way to now sort in descending order and to limit the number of posts on each page? I see the way it was done before is commented out and if it is uncommented an error occurs.

    //ORDER BY blogmain_date DESC LIMIT 5;
    Thanks for any help on this.

  4. #4
    Join Date
    Aug 2009
    Location
    Phoenix AZ
    Posts
    6

    Default Re: {next_prev} tag for blog_index.html template.

    Ok I played around with it a little bit and figured out that you can limit the number of pages by editing the following:
    $limit_str = $_GET['cur_page'] * $config['listings_per_page'];
    $recordSet = $conn->SelectLimit($sql, $config['listings_per_page'], $limit_str);
    if ($recordSet === false) {
    $misc->log_error($sql);
    }
    Change "$config['listings_per_page']" to the number of posts you would like on each page be sure to change each instance of the variable.

    Now to change the descending order you just have to ad "ORDER BY blogmain_date DESC" to the end of this code:

    $sql = "SELECT blogmain_full,blogmain_id FROM " . $config['table_prefix'] . "blogmain WHERE blogmain_published = 1";
    When you are done the line of code will look like "$sql = "SELECT blogmain_full,blogmain_id FROM " . $config['table_prefix'] . "blogmain WHERE blogmain_published = 1 ORDER BY blogmain_date DESC";

    I am just learning PHP and Open-Realty but this did work for me hope it helps someone else.

Similar Threads

  1. Template file /admin/template//main.html not found.
    By Jim Bullen in forum Installation/Configuration Help (CLOSED)
    Replies: 14
    Last Post: 09-14-2009, 09:49 PM
  2. Split the next_prev.html into a header and footer section?
    By Ivko in forum Templates - Help/Ideas/Discussion (CLOSED)
    Replies: 0
    Last Post: 05-28-2009, 05:27 AM
  3. next_prev - in admin edit_listings.html
    By bammhost in forum General Help (CLOSED)
    Replies: 1
    Last Post: 04-21-2008, 05:08 PM
  4. RSS.html Template
    By julianps in forum Installation/Configuration Help (CLOSED)
    Replies: 28
    Last Post: 05-02-2007, 01:36 PM
  5. next_prev template Addons
    By gimpdog in forum Addon Releases (FREE) (CLOSED)
    Replies: 0
    Last Post: 09-11-2006, 08:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •