Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Frage zu Paginate AddOn

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
2344223
Smarty Rookie


Joined: 31 Oct 2004
Posts: 5

PostPosted: Sun Oct 31, 2004 1:00 pm    Post subject: Frage zu Paginate AddOn Reply with quote

Hallo,

Erstmal möchte ich ein dickes Lob aussprechen. Smarty ist wirklich genial. Ich befasse mich erst seit 6 Wochen mit PHP, durch Smarty ist es mir aber schon jetzt gelungen eine recht professionelle Seite zu erstellen. Vielen Dank an die Entwickler, Smarty ist echt gold wert!!!

So, nun würde ich gerne Paginate verwenden, allerdings klappt das noch nicht so recht, habe da ein paar Verständnis Probleme.

Das Problem ist Paginate in Verbindung mit einem MySQL Datensatz... Mein code sieht wie folgt aus

[php:1:6b7ac5ad86]<?php
session_start();

// ####################### MySQL Verbindung ############################
require "../../../source/php/connect.php";
require "../../../source/php/class_db_exec_mysql.php";
$db = new db_exec;
$db->connect();

// ####################### Smarty für Templates ##########################
require('../../../source/smarty/libs/SmartyPaginate.class.php');
require 'setup.php';
$smarty =& new Smarty_screenshots;

// ####################### Screenshotdetails START #######################

//Kategorie
$kategorie = "Spiele";

//Item-ID
$spiel = $_REQUEST['id'];


// required connect
SmartyPaginate::connect();

// set items per page
SmartyPaginate::setLimit(1);



function get_db_results() {
// normally you would have an SQL query here,
// for this example we fabricate a 100 item array
// to paginate through
$query = "SELECT pic_big FROM screenshots WHERE categorie='game' AND item_id=1773";
$results = mysql_query( $query );
$_data = mysql_fetch_array( $results );

// set total number of items
SmartyPaginate::setTotal(count($_data));

// return our segment of data being displayed
// typically you might do this in a LIMIT clause from MySQL
// for this example, we slice an array of data
return array_slice($_data, SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
}

// assign your db results to the template
$smarty->assign('results', get_db_results());
// assign {$paginate} var
SmartyPaginate::assign($smarty);

// ####################### Templates mit "Smarty" anzeigen ###########################
$smarty->display('screenshots_details_head.tpl', $kategorie . $spiel);
$smarty->display('header.tpl');
$smarty->display('headnav.tpl');

$smarty->display('screenshots_details.tpl', $kategorie . $spiel . $next);
$smarty->display('footer.tpl');

?>[/php:1:6b7ac5ad86]

Und hier der Code im 'screenshots_details.tpl


Code:
{* display pagination header *}
    Items {$paginate.first}-{$paginate.last} out of {$paginate.total} displayed.

    {* display results *}   
    {section name=res loop=$results}
        <img src"{$results[res]}" height="275" width="420" border="0">
    {/section}

    {* display pagination info *}
    {paginate_prev} {paginate_middle} {paginate_next}


Also irgendwie klappt das nciht so recht, cih weiß auch nicht genau wie ich das beschreiben soll. Vielleicth kannt mir einfach jemand beschreiben wie ich nun mein SQL Datensatz in "Pagination" bekomme. Ich lese aus der MYSQL DB lediglich den Namen des images aus, also z.b. image1.jpg und es sind insgesamt 25 Images.

Ich weiß, das ist jetzt eine dürftige Problembeschreibung, aber vielleicht kann mir ja jemand helfen.

Liebe Grüße
Back to top
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Thu Nov 04, 2004 12:16 pm    Post subject: Reply with quote

[php:1:21681cfb2a]
function get_db_results() {
// normally you would have an SQL query here,
// for this example we fabricate a 100 item array
// to paginate through
$query = "SELECT pic_big FROM screenshots WHERE categorie='game' AND item_id=1773 LIMIT ". SmartyPaginate::getCurrentIndex() . " ". SmartyPaginate::getLimit();
$results = mysql_query( $query );
$_data = mysql_fetch_array( $results );

// set total number of items
SmartyPaginate::setTotal(count($_data));

// return our segment of data being displayed
// typically you might do this in a LIMIT clause from MySQL
// for this example, we slice an array of data
return $_data;
}

[/php:1:21681cfb2a]
Back to top
View user's profile Send private message
grawit
Smarty n00b


Joined: 09 Feb 2005
Posts: 2

PostPosted: Wed Feb 09, 2005 5:20 pm    Post subject: Reply with quote

Als eine Lternative kannst du dir auch mal ezPagination angucken, zusammen mit ezSQl, ist schon einfacher glaube ich als SmartyPaginate. =)
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP