Results 1 to 4 of 4

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

  1. #1
    Join Date
    Aug 2004
    Săo Paulo - Brasil.

    Default {next_prev} tag for blog_index.html template.


    Tested at SVN. Rev. 2531.

    At i just modified the function "disply_blog_index".

    PHP Code:
    function disply_blog_index(){
    $config['basepath'] . '/include/');
    //Load the Core Template
    require_once($config['basepath'] . '/include/class/template/');
    $misc = new misc();
    $page = new page_user();
    $config['basepath'] . '/include/');
    $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) {
    $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) {

    $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');
    $blog_entry_template $page->parse_template_section($blog_entry_template'blog_summary'$summary);
    $blog_entry_template $page->parse_template_section($blog_entry_template'blog_author'$blog_author);
    $blog_entry_template $page->parse_template_section($blog_entry_template'blog_comment_count'$blog_comment_count);
    $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);

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

    HTML Code:
    <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>
    Now is displayed based at listings_per_page configuration.

    [ ]´s

    ...a blind padawan...

  2. #2
    Join Date
    Apr 2006

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

    Very helpful. Thanks!

  3. #3
    Join Date
    Aug 2009
    Phoenix AZ

    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
    Phoenix AZ

    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) {
    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


Posting Permissions

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