Custom Page - Auto Pagination

62 views
Skip to first unread message

Adam

unread,
Mar 25, 2011, 4:14:18 PM3/25/11
to Magic Fields
Hi there!

I've created a custom page that displays a bunch of audio clips using
Magic Fields. For the setup, I essentially created a custom write
panel that contains a group with all the fields to post an audio clip.
Each time I want to add a new audio clip, I just have to duplicate the
group and post the new clip. Each clip gets added to the same page,
one after the other.

Everything seems to be working fine however, I realized that after a
while, the page is going to get quite long and will really start to
effect the page loading time. Is there any way that I can add some
simple pagination with the setup I have (similar to the pagination
that you get with the Wordpress blog)?

Any help would be greatly appreciated. If it helps, here is my code so
far (without pagination). Thanks.


$AudioClip = get_group("Audio Clip");
if($AudioClip){
foreach($AudioClip as $Audio){
echo '<div class="audio_clip">';
echo '<h3>' . $Audio['audio_clip_title'][1] . '</h3>';
echo '<p>' . $Audio['audio_clip_description'][1] . '</p>';

$mp3 = $Audio['audio_clip_file'][1];

if (function_exists('insert_audio_player')) {
insert_audio_player('[audio:' . $mp3 . ']' );
} else {
echo '<p><a href="' . $mp3 . '">Download</a></p>';
}
echo '</div>';
}
}

Adam

unread,
Mar 25, 2011, 4:23:09 PM3/25/11
to Magic Fields
Just to clarify - I know that when you're editing a page in Wordpress,
you can add the "<!--nextpage-->" shortcode in order to split your
pages up. Essentially what I'm looking to do is have this added after
let's say 10 audio clips are on the page. Is this easy to do based on
the setup I have? Or is there a better way to approach this? I'm
definitely open to suggestions.

Thanks guys.

chad totaro

unread,
Mar 25, 2011, 4:33:00 PM3/25/11
to magic-...@googlegroups.com
Yup,  I can add that breadcrumb.  You can see it on my blog.

bicyclenerd.com


Chad

Hunk

unread,
Mar 25, 2011, 5:03:09 PM3/25/11
to magic-...@googlegroups.com, chad totaro

Adam

unread,
Mar 25, 2011, 5:07:44 PM3/25/11
to Magic Fields
No worries Chad. Thanks for the reply anyway ;)

The question is still open if anyone has any ideas.

Adam

unread,
Mar 25, 2011, 5:26:54 PM3/25/11
to Magic Fields
Thanks for the reply Hunk.

I actually did stumble across that post earlier but couldn't get it to
work properly. I could only get it to display the first audio clip in
the group. The "Next Chapter" link would still appear but when
clicked, it just showed the same clip.

I'm not really an expert at PHP so it could be I'm just doing
something wrong. You can see my code below (its just a rework of your
code from that previous post). If you have any ideas of what I'm doing
wrong, I can really use the help. Thanks.

$chapter = 1;
if( isset($_GET['Audio Clip']) ){
$chapter = (int)$_GET['Audio Clip'];
if(!$chapter) $chapter = 1;
}
if( $chapter > 0){
$chapters = getGroupOrder('audio_clip_title');
if(in_array($chapter,$chapters)){
printf('<div class="audio_clip bg_gradient"><h3>%s</
h3>',get('audio_clip_title',$chapter));
printf('<p>%s</p>',get('audio_clip_description',$chapter));
printf('<p>Content: %s</p></div>',get('audio_clip_description',
$chapter));

$check = strpos(get_permalink(),'?p=');
if ($check === false) {
$pre = '?';
}else{
$pre = '&';
}
printf('<div>');
if($chapter > 1){
printf('<a href="%s%schapter=%s">Prev Chapter</a>
',get_permalink(),$pre,$chapter-1);
}

if( $chapter < count($chapters)){
printf('<a href="%s%schapter=%s">Next Chapter</
a>',get_permalink(),$pre,$chapter+1);
}
printf('</div>');
}
}


On Mar 25, 5:03 pm, Hunk <ing.ed...@gmail.com> wrote:
> Hi adam check this topichttps://groups.google.com/d/topic/magic-fields/F6-Gn2dCO-g/discussion

Adam

unread,
Mar 28, 2011, 8:14:02 AM3/28/11
to Magic Fields
Sorry to bump my question guys but I really need to get this working.
I've tried posting my question on other forms but haven't had much
luck.

Any help would be greatly appreciated. Thanks!
Reply all
Reply to author
Forward
0 new messages