• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Pagination for news articles.
PostPosted: Mon Jun 18, 2007 3:36 am 
Offline
Forum Members
Forum Members

Joined: Sun Jun 17, 2007 5:15 am
Posts: 23
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:







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.


Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Mon Jun 18, 2007 7:50 am 
Offline
Support Guru
Support Guru
User avatar

Joined: Mon Jul 04, 2005 5:12 pm
Posts: 4827
Location: Ferrara, Italy
Cobby wrote:
I need help simplifying in the pagination for news articles.
........


Look News SVN version for pagination

Alby

_________________
CMSMS Support Team
Italian Admin and Moderator

Plugins: Geolocate hostip, Multiple random image, Image rotator (beta), Content Pagination
Modules: ForumMadeSimple (Howto), TranslationManager
Multilingual: MLE is not CMSMS


Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Tue Jun 19, 2007 3:56 am 
Offline
Forum Members
Forum Members

Joined: Sun Jun 17, 2007 5:15 am
Posts: 23
alby wrote:
Cobby wrote:
I need help simplifying in the pagination for news articles.
........


Look News SVN version for pagination

Alby


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.

Cheers,
Cobby


Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Tue Jun 19, 2007 9:47 am 
Offline
Support Guru
Support Guru
User avatar

Joined: Mon Jul 04, 2005 5:12 pm
Posts: 4827
Location: Ferrara, Italy
Cobby 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.


Ok, my mistake, I don't read  :-X

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:

Quote:
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;
        }
    }
}



Quote:
{page name=Page1}
Page 1
{/page}

{page name=Page2}
Page 2
{/page}

{page name=Page3}
Page 3
{/page}

{page name=Page4}
Page 4
{/page}



_________________
CMSMS Support Team
Italian Admin and Moderator

Plugins: Geolocate hostip, Multiple random image, Image rotator (beta), Content Pagination
Modules: ForumMadeSimple (Howto), TranslationManager
Multilingual: MLE is not CMSMS


Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Thu Jun 21, 2007 2:16 am 
Offline
Forum Members
Forum Members

Joined: Sun Jun 17, 2007 5:15 am
Posts: 23
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}
Code:
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>";


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:
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>";


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:
Code:
while($i<$p){                                       
   echo "\"\$params['page$i']\", ";
   $i++;
}

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


Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Thu Jun 21, 2007 7:29 am 
Offline
Support Guru
Support Guru
User avatar

Joined: Mon Jul 04, 2005 5:12 pm
Posts: 4827
Location: Ferrara, Italy
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}
Code:
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>";


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:
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>";


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:
Code:
while($i<$p){                                       
   echo ""\$params['page$i']", ";
   $i++;
}

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?



Try with:

Quote:
echo '';

global $page;
global $p;
$i = 1;  // is a integer
$pages = '';

while($i<$p){
$pages .= """.$params['page$i']."", ";
$i++;
}
$pages = substr($pages, 0, -1); // clean last comma


echo "";


Alby

_________________
CMSMS Support Team
Italian Admin and Moderator

Plugins: Geolocate hostip, Multiple random image, Image rotator (beta), Content Pagination
Modules: ForumMadeSimple (Howto), TranslationManager
Multilingual: MLE is not CMSMS


Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Thu Jun 21, 2007 8:27 am 
Offline
Forum Members
Forum Members

Joined: Sun Jun 17, 2007 5:15 am
Posts: 23
alby wrote:
Try with:

Quote:
echo '';

global $page;
global $p;
$i = 1;  // is a integer
$pages = '';

while($i<$p){
$pages .= """.$params['page$i']."", ";
$i++;
}
$pages = substr($pages, 0, -1); // clean last comma


echo "";


Alby


That didn't work :(
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


Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Thu Jun 21, 2007 8:38 am 
Offline
Support Guru
Support Guru
User avatar

Joined: Mon Jul 04, 2005 5:12 pm
Posts: 4827
Location: Ferrara, Italy
Cobby wrote:
alby wrote:
Try with:

Quote:
echo '';

global $page;
global $p;
$i = 1;  // is a integer
$pages = '';

while($i<$p){
$pages .= """.$params['page$i']."", ";
$i++;
}
$pages = substr($pages, 0, -1); // clean last comma


echo "";


Alby


That didn't work :(
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 :)


Sorry, my mistake, change to (for page$i):

Quote:
$pages .= '"'. $params['page$'.$i] .'",';  // no space after comma

_________________
CMSMS Support Team
Italian Admin and Moderator

Plugins: Geolocate hostip, Multiple random image, Image rotator (beta), Content Pagination
Modules: ForumMadeSimple (Howto), TranslationManager
Multilingual: MLE is not CMSMS


Last edited by alby on Thu Jun 21, 2007 8:45 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Thu Jun 21, 2007 9:02 am 
Offline
Forum Members
Forum Members

Joined: Sun Jun 17, 2007 5:15 am
Posts: 23
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.


Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Thu Jun 21, 2007 9:09 am 
Offline
Forum Members
Forum Members

Joined: Sun Jun 17, 2007 5:15 am
Posts: 23
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 :P

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:
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


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


Last edited by Cobby on Thu Jun 21, 2007 9:27 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Sun Jul 01, 2007 8:45 am 
Offline
Forum Members
Forum Members

Joined: Sun Jun 17, 2007 5:15 am
Posts: 23
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.


Top
 Profile  
 
 Post subject: Re: Pagination for news articles.
PostPosted: Mon Sep 24, 2007 8:04 am 
Offline
Support Guru
Support Guru
User avatar

Joined: Mon Jul 04, 2005 5:12 pm
Posts: 4827
Location: Ferrara, Italy
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 have resumed the job on this in order to see to generalize it and apply ALL features.
I hope to publish it tomorrow for a test

Alby

_________________
CMSMS Support Team
Italian Admin and Moderator

Plugins: Geolocate hostip, Multiple random image, Image rotator (beta), Content Pagination
Modules: ForumMadeSimple (Howto), TranslationManager
Multilingual: MLE is not CMSMS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


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 post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner