I try create my plug-in like a little blog on mainpage of piwigo. It is allready working on my local server - posts from database showing on mainpage, just need cosmetic improvements. I stopped at paginal output. I try use standart GET-method to send page numbers for script, but piwigo dont understand it and display only simple mainpage. In 'additional pages' plug-in I spied array $tokens and try use it like in 'additional pages' - no effect. Can you advise something? Somewhere exist a technical documentation in English?
Last edited by EvilKant (2012-04-06 14:21:22)
Offline
Hello
good news to see someone doing a great usefull project like that
Could you show us some code ?
About docs, the French one is much more documented, but not so technical; the best way is to learn with examples. I did the same
Offline
posts.tpl
{php} global $tokens; $post_per_page = 5; ///////Here I try get number of page from previous session/////////////// if ($tokens[0] == 'blog_page') { if ((!empty($tokens[1])) and ($tokens[1]<=0)) { $number = 0; } else { $npage = $tokens[1]; $number=($tokens[1]-1)*$post_per_page; } } else { $number = 0; } ///////////////////////////////////////////////////////////////////////////////////// error_reporting(0); $link = mysqli_connect("localhost", "*****", "*****", "picmun"); if (!$link) { echo "MySQL говорит об ошибке: " . mysqli_connect_error(); } $query = "SELECT * FROM `evil_blog` WHERE 1 ORDER BY `date` DESC LIMIT ".$number.",".$post_per_page; $result = mysqli_query($link, $query); {/php} <div class='content' id="comments"> <div class="titrePage">Новости! <ul class="categoryActions"><li> </li></ul> </div> <ul class="thumbnailCategories"> {php} while ($row = mysqli_fetch_array($result)) { {/php} <li> <div class="thumbnailCategory"> {php} echo $row["id"]."* ". $row["date"]." - ".$row["header"];{/php} <div class="description"> {php} echo $row["text"];{/php} </div> </div> </li> {php} } {/php} </ul> <form action="" method="GET"> {php} $result = mysqli_query($link, "SELECT COUNT(*) FROM `evil_blog`"); $row = mysqli_fetch_array($result); $pages = ($row["COUNT(*)"] / $post_per_page)+1; {/php} ///////////////////////////Navigation Bar/////////////////////////////////////// <div class="navigationBar"> <a href="index.php" rel="first">{'First'|@translate}</a> | <a href="index.php?/blog_page/{php}echo $npage-1;{/php}" rel="prev">{'Previous'|@translate}</a> | {php} for ($it=1; $it<=$pages; $it++) { echo '<span class=""><a href="index.php?/blog_page/'.$it.'">'.$it.'</a> | </span>'; } {/php} <a href="index.php?/blog_page/{php}echo $npage+1;{/php}" rel="next">{'Next'|@translate}</a> | <a href="index.php?/blog_page/{php}echo $pages;{/php}" rel="last">{'Last'|@translate}</a> </div> //////////////////////////////////////////////////////////////////////////////////// </form> </div> {php} mysqli_close($link); {/php}
I don't use SMARTY, becouse I want learn PHP.
Maybe I must register $tokens's values? But in "Additional pages" I have not found something like this.
Last edited by EvilKant (2012-04-07 11:37:15)
Offline
I think you just misunderstood the tokens : its a security protection when sensible data are transmitted. A unique string is generated for a very limited time : it's the token
The pagination is used -as far as i remember- in the global $page : you can use this variable too
Offline
I forgot about POST-method. Whith POST all is working... Now I need turn <a> to "submit".
Offline
Damn... I begin hate jQuery...
If I do this:
echo "<input type='text' name='npage'>"; echo "<input type='submit' value='Send'>";
All is working. I can see and first, and second page of blog.
But if I try do this with jQuery, all is not working:
<script type="text/javascript">{literal} $(function(){ $('.blog_pagination').click(function() { $.post('index.php', {npage: '2'}); //here I just want see second page, but still see first page, and $_POST array still empty. }); return false; }); {/literal} </script> <a class='blog_pagination' href='' rel='".$it."'>".$it."</a>
I think, I misunderstood $.post function, but google can't advise something other... Everything works except line with $.post .
Until I find a solution to this problem, I can't begin do other parts :( . Without paginal output plugin will be unusable.
Offline
At last I found a solution! I did hidden input and with javascript send data like from form.
<script type="text/javascript">{literal} function subnum (num) { document.blog_pagination.npage.value=num; document.blog_pagination.submit(); } {/literal} </script> {php} echo "<input type='text' name='npage' style='visibility: hidden; position: absolute;'>"; for ($it=1; $it<=$pages; $it++) { echo "<a class='blog_pagination' href='#' onclick='subnum("; echo '"'.$it.'"'; echo ")'>".$it."</a> | "; } {/php}
Offline
EvilKant wrote:
:-)
Can you add on SVN ?
Offline
ddtddt wrote:
:-)
Can you add on SVN ?
First I must understand how it works
Offline
EvilKant wrote:
ddtddt wrote:
:-)
Can you add on SVN ?First I must understand how it works
What your OS ?
mac ? linux ? windows ?
Offline
ddtddt wrote:
What your OS ?
mac ? linux ? windows ?
windows XP
Offline
EvilKant wrote:
ddtddt wrote:
What your OS ?
mac ? linux ? windows ?windows XP
Dowload and install tortoiseSVN -> http://tortoisesvn.net/downloads.html ;-)
Offline
Hi there, I've not got this installed yet, but it sounds great - are you going to update it for 2.4?
Offline
skpManiac wrote:
Hi there, I've not got this installed yet, but it sounds great - are you going to update it for 2.4?
EdwinKort wrote:
And it works with 2.4 :)
Offline