Pagination for news articles.
Pagination for news articles.
Hi everyone,
I need help simplifying in the pagination for news articles.
I using the system that can be found (with instructions) at http://www.dynamicdrive.com/dynamicinde ... nation.htm.
Its all done in javascript, but you don't need to know javascript to use it. To get this working, I need people who know HTML and PHP (mainly PHP).
This javascript pagination system can be easily adapted into CMSMS, but when creating news articles, it hard.
I want to create user defined tags in order to make it much more simpler for those editors who don't understand programming.
For the development, we will user Demo 5, which is the one with the drop down box.
All of the pages in the article need to be split up with tags. So instaed of getting editors to put:
...
to separate pages.
Will can make UDT.
{spage} //s is for start
echo "";
{epage} //e is for end
echo "";
I was planing on using {page} and {/page} like the if statement, but I got errors because / is an invalid character, does anyone know away around this?
At the end of each page, we need to add the following code:
Prev Next
var gallery=new virtualpaginate("virtualpage5", 1)
gallery.buildpagination("galleryselect", ["castle", "park", "harvest", "country"])
In the there is the line
gallery.buildpagination("galleryselect", ["castle", "park", "harvest", "country"])
castle, park, harvest, country, all represent the values for each page, these appear in the drop down box aswell.
Firstly, instead of adding that to the bottom of the page, will put it in a UDT, we will call it pagination.
So that works all fine. But we obviously don't want every article to have 4 pages called caste, park, harvest and country do we. We can use the $params['text here'] variable so that the editors can name their pages. So we can change it to:
gallery.buildpagination("galleryselect", [\"".$params['page1']."\", \"".$params['page2']\", \"".$params[page3']\", \"".$params['page4']."\"])
Well thats all plan and simple, isn't it. Now all the edit has to do for an arictle is type:
{spage}
Page 1
{epage}
{spage}
Page 2
{epage}
{spage}
Page 3
{epage}
{spage}
Page 4
{epage}
{pagination page1="Page 1" page2="Page 2" page3="Page 3" page4="Page 4"} //that will automatically fill the javascript section.
But now for the tricky part...
What if the article had 7 pages? That would mean the editor would have to edit the UDT, and change that javascript line, everytime he want to make a new article that was different length to the last. Yes, this is where I got stuck and now need help.
We need it to automatically count the number of pages the user has created. Anyone can do that, just add $i++ to {spage}.
But for every page, me need to make a new variable, and then output that into the javascript section, with the valid syntax.
How do we get it to do this, that I don't not know, and I now need help from a more advanced programmer.
Cheers,
Cobby
Sorry for the unorganized post, but I found it difficult to explain my question.
I need help simplifying in the pagination for news articles.
I using the system that can be found (with instructions) at http://www.dynamicdrive.com/dynamicinde ... nation.htm.
Its all done in javascript, but you don't need to know javascript to use it. To get this working, I need people who know HTML and PHP (mainly PHP).
This javascript pagination system can be easily adapted into CMSMS, but when creating news articles, it hard.
I want to create user defined tags in order to make it much more simpler for those editors who don't understand programming.
For the development, we will user Demo 5, which is the one with the drop down box.
All of the pages in the article need to be split up with tags. So instaed of getting editors to put:
...
to separate pages.
Will can make UDT.
{spage} //s is for start
echo "";
{epage} //e is for end
echo "";
I was planing on using {page} and {/page} like the if statement, but I got errors because / is an invalid character, does anyone know away around this?
At the end of each page, we need to add the following code:
Prev Next
var gallery=new virtualpaginate("virtualpage5", 1)
gallery.buildpagination("galleryselect", ["castle", "park", "harvest", "country"])
In the there is the line
gallery.buildpagination("galleryselect", ["castle", "park", "harvest", "country"])
castle, park, harvest, country, all represent the values for each page, these appear in the drop down box aswell.
Firstly, instead of adding that to the bottom of the page, will put it in a UDT, we will call it pagination.
So that works all fine. But we obviously don't want every article to have 4 pages called caste, park, harvest and country do we. We can use the $params['text here'] variable so that the editors can name their pages. So we can change it to:
gallery.buildpagination("galleryselect", [\"".$params['page1']."\", \"".$params['page2']\", \"".$params[page3']\", \"".$params['page4']."\"])
Well thats all plan and simple, isn't it. Now all the edit has to do for an arictle is type:
{spage}
Page 1
{epage}
{spage}
Page 2
{epage}
{spage}
Page 3
{epage}
{spage}
Page 4
{epage}
{pagination page1="Page 1" page2="Page 2" page3="Page 3" page4="Page 4"} //that will automatically fill the javascript section.
But now for the tricky part...
What if the article had 7 pages? That would mean the editor would have to edit the UDT, and change that javascript line, everytime he want to make a new article that was different length to the last. Yes, this is where I got stuck and now need help.
We need it to automatically count the number of pages the user has created. Anyone can do that, just add $i++ to {spage}.
But for every page, me need to make a new variable, and then output that into the javascript section, with the valid syntax.
How do we get it to do this, that I don't not know, and I now need help from a more advanced programmer.
Cheers,
Cobby
Sorry for the unorganized post, but I found it difficult to explain my question.
Re: Pagination for news articles.
Look News SVN version for paginationCobby wrote: I need help simplifying in the pagination for news articles.
........
Alby
Re: Pagination for news articles.
Could you ellaborate a little more.alby wrote:Look News SVN version for paginationCobby wrote: I need help simplifying in the pagination for news articles.
........
Alby
I know there was pagination add for the list of news articles. But I want to make pages for the contents of the articles.
Cheers,
Cobby
Re: Pagination for news articles.
Ok, my mistake, I don't readCobby wrote: Could you ellaborate a little more.
I know there was pagination add for the list of news articles. But I want to make pages for the contents of the articles.

However your method would to work with any content and not news content only.
My idea (but only idea very very very .... UNTESTED):
Use function block and {page name="XXXX"}{/page} tag:
function smarty_block_page($params, $content, &$smarty, &$repeat)
{
if(!$repeat){
if (isset($content)) {
if (! isset($smarty->endpagination)) {
$smarty->endpagination = 'gallery.buildpagination("galleryselect"; [';
}
$smarty->endpagination .= '"'. $params['name'] .'"';
$smarty->assign('endpagination', $smarty->endpagination .']');
// do some intelligent thing here with $content
return $content;
}
}
}
{page name=Page1}
Page 1
{/page}
{page name=Page2}
Page 2
{/page}
{page name=Page3}
Page 3
{/page}
{page name=Page4}
Page 4
{/page}
var gallery=new virtualpaginate("virtualpage5", 1)
{$endpagination}
Re: Pagination for news articles.
Well I decided to go against your function idea, mainly because I am still a novice, and I don't understand some of the code.
But I am so close. The only problem I am having now, is when you put {pagination page1="PG 1"....}
It output nothing.
In {sp} (opens the ) I have a counted.
And this is the code for {paignation}
With that code it didn't work, the option in the drop down bow where simply blank. So I did a little problem solving. I adjusted {pagination} to this:
And long behold, it is in fact just outputting "", "", "", .
So I know I am just doing something wrong with the $params stuff.
Can anyone see what I am doing wrong?
I also modified that second loop I add to:
And it outputted "$params['page1']", "$params['page2']", "$params['page3']",
So I know it is being told the correct page numbers.
So how do I rectify this $params problem?
Cheers,
Cobby
But I am so close. The only problem I am having now, is when you put {pagination page1="PG 1"....}
It output nothing.
In {sp} (opens the ) I have a counted.
And this is the code for {paignation}
Code: Select all
echo '<div id="galleryselect" class="paginationstyle">
<a href="#" rel="previous">Prev</a> <select style="width: 120px"></select> <a href="#" rel="next">Next</a>
</div>';
global $page;
global $p;
$i = '1';
echo "<__script__ type=\"text/javascript\">
var gallery=new virtualpaginate(\"virtualpage5\", 1)
gallery.buildpagination(\"galleryselect\", [";
while($i<$p){
echo "\"".$params['page$i']."\", ";
$i++;
}
echo "])
</__script>";
Code: Select all
echo '<div id="galleryselect" class="paginationstyle">
<a href="#" rel="previous">Prev</a> <select style="width: 120px"></select> <a href="#" rel="next">Next</a>
</div>';
global $page;
global $p;
$i = '1';
while($i<$p){ ///Add a second, yet identical, while loop outside the javascript
echo "\"".$params['page$i']."\", ";
$i++;
}
echo "<__script__ type=\"text/javascript\">
var gallery=new virtualpaginate(\"virtualpage5\", 1)
gallery.buildpagination(\"galleryselect\", [";
while($i<$p){
echo "\"".$params['page$i']."\", ";
$i++;
}
echo "])
</__script>";
So I know I am just doing something wrong with the $params stuff.
Can anyone see what I am doing wrong?
I also modified that second loop I add to:
Code: Select all
while($i<$p){
echo "\"\$params['page$i']\", ";
$i++;
}
So I know it is being told the correct page numbers.
So how do I rectify this $params problem?
Cheers,
Cobby
Re: Pagination for news articles.
Try with:Cobby wrote: Well I decided to go against your function idea, mainly because I am still a novice, and I don't understand some of the code.
But I am so close. The only problem I am having now, is when you put {pagination page1="PG 1"....}
It output nothing.
In {sp} (opens the ) I have a counted.
And this is the code for {paignation}With that code it didn't work, the option in the drop down bow where simply blank. So I did a little problem solving. I adjusted {pagination} to this:Code: Select all
echo '<div id="galleryselect" class="paginationstyle"> <a href="#" rel="previous">Prev</a> <select style="width: 120px"></select> <a href="#" rel="next">Next</a> </div>'; global $page; global $p; $i = '1'; echo "<__script__ type="text/javascript"> var gallery=new virtualpaginate("virtualpage5", 1) gallery.buildpagination("galleryselect", ["; while($i<$p){ echo """.$params['page$i']."", "; $i++; } echo "]) </__script>";
And long behold, it is in fact just outputting "", "", "", .Code: Select all
echo '<div id="galleryselect" class="paginationstyle"> <a href="#" rel="previous">Prev</a> <select style="width: 120px"></select> <a href="#" rel="next">Next</a> </div>'; global $page; global $p; $i = '1'; while($i<$p){ ///Add a second, yet identical, while loop outside the javascript echo """.$params['page$i']."", "; $i++; } echo "<__script__ type="text/javascript"> var gallery=new virtualpaginate("virtualpage5", 1) gallery.buildpagination("galleryselect", ["; while($i<$p){ echo """.$params['page$i']."", "; $i++; } echo "]) </__script>";
So I know I am just doing something wrong with the $params stuff.
Can anyone see what I am doing wrong?
I also modified that second loop I add to:And it outputted "$params['page1']", "$params['page2']", "$params['page3']",Code: Select all
while($i<$p){ echo ""\$params['page$i']", "; $i++; }
So I know it is being told the correct page numbers.
So how do I rectify this $params problem?
Albyecho '
Prev Next
';
global $page;
global $p;
$i = 1; // is a integer
$pages = '';
while($i
var gallery=new virtualpaginate("virtualpage5", 1)
gallery.buildpagination("galleryselect", [$pages])
";
Re: Pagination for news articles.
That didn't workalby wrote: Try with:
Albyecho '
Prev Next
';
global $page;
global $p;
$i = 1; // is a integer
$pages = '';
while($i
var gallery=new virtualpaginate("virtualpage5", 1)
gallery.buildpagination("galleryselect", [$pages])
";

But I have found out the problem. It does like have the $1 in $params['page$i']. I think having that it will then be {pagination page$i="P1"}
I don't know how to get around this though

Your help is really appreciated though

Cheers,
Cobby
Re: Pagination for news articles.
Sorry, my mistake, change to (for page$i):Cobby wrote:That didn't workalby wrote: Try with:
Albyecho '
Prev Next
';
global $page;
global $p;
$i = 1; // is a integer
$pages = '';
while($i
var gallery=new virtualpaginate("virtualpage5", 1)
gallery.buildpagination("galleryselect", [$pages])
";
But I have found out the problem. It does like have the $1 in $params['page$i']. I think having that it will then be {pagination page$i="P1"}
I don't know how to get around this though
Your help is really appreciated though![]()
$pages .= '"'. $params['page$'.$i] .'",'; // no space after comma
Last edited by alby on Thu Jun 21, 2007 8:45 am, edited 1 time in total.
Re: Pagination for news articles.
No sorry, my mistake, I meant to say it doesn't like to have the $i in $params['page$i'].
Few typos, sorry.
I think I need to store it in an array, then extract that array, so its final will be $params['page1'] instead of $params['page$i']. But I know how to do that either, but am currently working on it.
Few typos, sorry.
I think I need to store it in an array, then extract that array, so its final will be $params['page1'] instead of $params['page$i']. But I know how to do that either, but am currently working on it.
Re: Pagination for news articles.
Ah its getting so close!
I now have the $params working, just with a 3 page article, the drop down box will repeat the title for page 1 twice, then page 2
I guess its something with the loop, so I will investigate.
EDIT: Also, you forgot to add the echo $pages; in aswell
EDIT2: I did a little testing, I got it to echo $pages at the bottom of the script, and it displayed correctly, as it should:
"Page 1", "Page 2", "Page 3"
The correct syntax require between the square brackets in the line of javascript is as follows:
["Page 1", "Page 2", "Page 3"]
I thought it might have something to do with the last comma, si manually enter the details in to the javascript line myself as:
["Page 1", "Page 2", "Page 3", ]
And that didn't seem to bother it.
Here is what I have in for {pagination}
And here is what I am entering in the page:
{sp}This is page 1, the introduction.{ep}
{sp}This is page 2, the main body.{ep}
{sp}This is page 3, the conclusion.{ep}
{pagination page1="Page 1" page2="Page 2" page3="Page 3"}
And you can see the result at -> http://www.diycomputing.com.au/index.php?page=pagination
Cheers,
Cobby
I now have the $params working, just with a 3 page article, the drop down box will repeat the title for page 1 twice, then page 2

I guess its something with the loop, so I will investigate.
EDIT: Also, you forgot to add the echo $pages; in aswell

EDIT2: I did a little testing, I got it to echo $pages at the bottom of the script, and it displayed correctly, as it should:
"Page 1", "Page 2", "Page 3"
The correct syntax require between the square brackets in the line of javascript is as follows:
["Page 1", "Page 2", "Page 3"]
I thought it might have something to do with the last comma, si manually enter the details in to the javascript line myself as:
["Page 1", "Page 2", "Page 3", ]
And that didn't seem to bother it.
Here is what I have in for {pagination}
Code: Select all
echo '<div id="galleryselect" class="paginationstyle">
<a href="#" rel="previous">Prev</a> <select style="width: 120px"></select> <a href="#" rel="next">Next</a>
</div>';
global $page;
global $p;
$i = 1;
echo "<__script__ type=\"text/javascript\">
var gallery=new virtualpaginate(\"virtualpage5\", 1)
gallery.buildpagination(\"galleryselect\", [";
$pages = '';
while($i<$p){
$pages .= '"'.$params['page'.$i].'", ';
echo $pages;
$i++;
}
$pages = substr($pages, 0, -2); // clean last comma
echo "])
</__script>";
echo $pages; //second echo to see that it is outputting correctly
{sp}This is page 1, the introduction.{ep}
{sp}This is page 2, the main body.{ep}
{sp}This is page 3, the conclusion.{ep}
{pagination page1="Page 1" page2="Page 2" page3="Page 3"}
And you can see the result at -> http://www.diycomputing.com.au/index.php?page=pagination
Cheers,
Cobby
Last edited by Cobby on Thu Jun 21, 2007 9:27 am, edited 1 time in total.
Re: Pagination for news articles.
I got it working! All is good now, thanks for your help alby. When my website is finished I will add it to the dev area for others to use.
Re: Pagination for news articles.
I have resumed the job on this in order to see to generalize it and apply ALL features.Cobby wrote: I got it working! All is good now, thanks for your help alby. When my website is finished I will add it to the dev area for others to use.
I hope to publish it tomorrow for a test
Alby