• 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  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Previous and next article in news details page
PostPosted: Tue Nov 02, 2010 7:07 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 01, 2009 6:03 pm
Posts: 186
Location: Plzen, CZ
folco3 \folco3:
This is cool can it be modified into CGBlog?

sure, here is modified prev_next UDT for CGBlog:
\$1:
if (!function_exists('MyGetModuleInstance'))
{
        function &MyGetModuleInstance($module)
        {
                global $gCms;

                if (isset($gCms->modules[$module]) &&
                        $gCms->modules[$module]['installed'] == true &&
                        $gCms->modules[$module]['active'] == true)
                {
                        return $gCms->modules[$module]['object'];
                }
                // Fix only variable references should be returned by reference
                $tmp = FALSE;
                return $tmp;
        }
}

global $gCms;
$db = &$gCms->db;

$cgblog = MyGetModuleInstance('CGBlog');


$pageid = ($_REQUEST['pageid']) ? $_REQUEST['pageid'] : $params['pageid'];
$currdate = $params['currdate'];
if(!$currdate) return;

// get all news articles sorted by ascending date
$query_next = "SELECT cgblog_id,cgblog_title FROM  ".cms_db_prefix()."module_cgblog WHERE cgblog_date > ? AND status = 'published' ORDER BY cgblog_date ASC LIMIT 1";
$query_prev = "SELECT cgblog_id,cgblog_title FROM ".cms_db_prefix()."module_cgblog WHERE cgblog_date < ? AND status = 'published' ORDER BY cgblog_date DESC  LIMIT 1";

$result_next = &$db->GetRow($query_next,array($currdate));
$result_prev = &$db->GetRow($query_prev,array($currdate));

if($result_next['cgblog_id']) {
$aliased_title = munge_string_to_url($result_next['cgblog_title']);
$prettyurl = 'aktuality/' . $result_next["cgblog_id"] .'/'.$pageid."/$aliased_title";
$next_uri = $cgblog->CreateLink('cntnt01', 'detail', $pageid, '', array('articleid' => $result_next["cgblog_id"]) ,'', true, false, '', true, $prettyurl);
}else{
$next_uri = "";
}


if($result_prev['cgblog_id']) {
$aliased_title = munge_string_to_url($result_prev['cgblog_title']);
$prettyurl = 'aktuality/' . $result_prev["cgblog_id"] .'/'.$pageid."/$aliased_title";
$prev_uri = $cgblog->CreateLink('cntnt02', 'detail', $pageid, '', array('articleid' => $result_prev["cgblog_id"]) ,'', true, false, '', true, $prettyurl);
}else{
$prev_uri = "";
}

$smarty->assign('cgblog_next_url', $next_uri);
$smarty->assign('cgblog_next_text', $cgblog->lang("next"));
$smarty->assign('cgblog_prev_url', $prev_uri);
$smarty->assign('cgblog_prev_text', $cgblog->lang("prev"));


and code for detail template:
\$1:
{prev_next pageid=$page_id currid=$entry->id currdate=$entry->postdate}
<p>
{if $cgblog_next_url}<a href="{$cgblog_next_url}"><< {$cgblog_next_text}</a> | {/if}
{if $cgblog_prev_url}<a href="{$cgblog_prev_url}">{$cgblog_prev_text} >></a>{/if}
<p>


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Previous and next article in news details page
PostPosted: Mon Nov 07, 2011 11:00 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Fri Nov 28, 2008 11:26 am
Posts: 103
Location: London, UK
Hi all,

I know this was asked a couple of times previously, but i didn't see an obvious answer... Is it possible to amends the code above for CGBlog to allow the Prev/Next to stick to the current category?

This code is awesome, if I can just work it out it for the current category, it would be even better!

Thanks.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Previous and next article in news details page
PostPosted: Mon Dec 05, 2011 1:11 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1865
Location: The Netherlands
I think the SQL-code would look like something like this (just the select statement):

\$1:
// get all CGBlog articles sorted by ascending date (NEXT)
$query_next = "SELECT cgblog_id, cgblog_title
FROM ".cms_db_prefix()."module_cgblog
WHERE cgblog_date > ?
AND status = 'published'
AND (end_time >= CURRENT_DATE OR end_time IS NULL)
AND cgblog_id
IN (SELECT blog_id FROM ".cms_db_prefix()."module_cgblog_blog_categories)
ORDER BY cgblog_date
ASC LIMIT 1";

// get all CGBlog articles sorted by ascending date (PREV)
$query_prev = "SELECT cgblog_id, cgblog_title
FROM ".cms_db_prefix()."module_cgblog
WHERE cgblog_date < ?
AND status = 'published'
AND (end_time >= CURRENT_DATE OR end_time IS NULL)
AND cgblog_id
IN (SELECT blog_id FROM ".cms_db_prefix()."module_cgblog_blog_categories)
ORDER BY cgblog_date
ASC LIMIT 1";


However, a quick test learned that this is not working very. Had not had the time to look into it. Some help would be very helpfull.

Gregor


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Previous and next article in news details page
PostPosted: Sun Dec 11, 2011 7:27 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Mar 23, 2006 9:25 am
Posts: 1865
Location: The Netherlands
While using the sql-editor in phpmyadmin, I came to the following code that works in selecting the accoriding blog-items that are releated to a certain blog_id, in the code @blog_id
\$1:
select cgblog_title, cgblog_data
from cms_module_cgblog
where cgblog_id in ((select blog_id
from cms_module_cgblog_blog_categories
where category_id in
(select category_id
from cms_module_cgblog_blog_categories
where blog_id = '272' )));


Problem, it is pretty slow and require some improvement....

Gregor


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Previous and next article in news details page
PostPosted: Mon Dec 12, 2011 5:35 pm 
Offline
Forum Members
Forum Members

Joined: Sun Jan 23, 2011 1:55 am
Posts: 20
osxfil \osxfil:
folco3 \folco3:
This is cool can it be modified into CGBlog?

sure, here is modified prev_next UDT for CGBlog:
...

Hi osxfil.
I have been using your prev_nest UDT for CGBlog and really like it.
However, after upgrading to 1.10, it is broken on my site.
From the upgrade notes, it appears the problem may be due to using the $gCms->modules array.
Do you have an updated version compatible with 1.10.x?
Thanks
Bob


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Previous and next article in news details page
PostPosted: Thu May 24, 2012 11:11 am 
This thread has the updated UDT and another solution provided my Manuel: viewtopic.php?f=4&t=58551


Top
   
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

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: