• 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  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: CGBlog - Next/Previous Links? [SOLVED]
PostPosted: Wed Aug 10, 2011 12:58 pm 
Offline
Power Poster
Power Poster

Joined: Sat Feb 02, 2008 12:42 am
Posts: 424
Location: USA
Using the latest versions of CMSMS and CGBlog, is it possible to display links to previous and next posts, similar to the cms_selflink tag?

Thanks.


Last edited by Ziggywigged on Fri Sep 02, 2011 1:26 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links?
PostPosted: Tue Aug 30, 2011 1:45 pm 
Offline
Forum Members
Forum Members

Joined: Mon Feb 21, 2011 2:08 am
Posts: 50
I am experimenting with the same thing.. Anyone have ideas or solutions?

Even if it's an idea.. post it and it may spark someone else to figure out the solution.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links?
PostPosted: Fri Sep 02, 2011 3:08 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 01, 2009 6:03 pm
Posts: 168
Location: Plzen, CZ
Hi guys, it's very simple:
Code:
{prev_next pageid=$page_id currid=$entry->id currdate=$entry->postdate}
{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}


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links?
PostPosted: Fri Sep 02, 2011 3:37 am 
Offline
Forum Members
Forum Members

Joined: Mon Feb 21, 2011 2:08 am
Posts: 50
osxfil wrote:
Hi guys, it's very simple:
Code:
{prev_next pageid=$page_id currid=$entry->id currdate=$entry->postdate}
{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}


Maybe I'm missing something but all I get are errors using this code: string(138) "Smarty error: syntax error: unrecognized tag 'prev_next' (Smarty_Compiler.class.php, line 590)"


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links?
PostPosted: Fri Sep 02, 2011 4:19 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 01, 2009 6:03 pm
Posts: 168
Location: Plzen, CZ
i'm sorry :) UDT prev_next was missing:

Code:
if (!function_exists('MyGetModuleInstance'))
{
        function &MyGetModuleInstance($module)
        {
                $gCms = cmsms();

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

$gCms = cmsms();
$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"));


On end you need add to your CGBlog language XML prev and next text strings.


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links?
PostPosted: Fri Sep 02, 2011 4:46 am 
Offline
Forum Members
Forum Members

Joined: Mon Feb 21, 2011 2:08 am
Posts: 50
Still not sure what is wrong.. Now this is what shows on the page:

<< --Add Me - module:CGBlog string:next-- | --Add Me - module:CGBlog string:prev-- >>

Links show, but they do not work? I also think you have some items hard coded in the UDT like: 'aktuality/' I'll play around with it and see if i can tweak your UDT to get it to work.

Have you gotten yours to work with images yet?


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links?
PostPosted: Fri Sep 02, 2011 5:26 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Wed Apr 01, 2009 6:03 pm
Posts: 168
Location: Plzen, CZ
Bilmartech wrote:
Still not sure what is wrong.. Now this is what shows on the page:

<< --Add Me - module:CGBlog string:next-- | --Add Me - module:CGBlog string:prev-- >>

Links show, but they do not work? I also think you have some items hard coded in the UDT like: 'aktuality/' I'll play around with it and see if i can tweak your UDT to get it to work.

Have you gotten yours to work with images yet?


As i wrote – you need add into language file in CGBlog terms for previous and next strings. If you use english language, then open in some editor this file from your web: modules/CGBlog/lang/en_US.php and insert these two lines:
Code:
$lang['next'] = "Next";
$lang['prev'] = "Previous";


In UDT you need change in this two lines term 'aktuality/' to your pretty URL prefix, which you use for CGBlog module (you can find this setting in you CGBlog module administration under tab Settings, filed "Prefix to use on all URLS from the blog module:":
Code:
$prettyurl = 'aktuality/' . $result_next["cgblog_id"] .'/'.$pageid."/$aliased_title";

and
Code:
$prettyurl = 'aktuality/' . $result_prev["cgblog_id"] .'/'.$pageid."/$aliased_title";


Example of this solution you can find here: http://www.packaging-cz.cz/cz/aktuality/


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links?
PostPosted: Fri Sep 02, 2011 5:31 am 
Offline
Forum Members
Forum Members

Joined: Mon Feb 21, 2011 2:08 am
Posts: 50
Ok... I got the links working just fine now.. what I need help with please is to get the Alt tags on the images to display the correct title of the corresponding blog.

I have assigned a var in the template: {assign var='blogtitle' value=$entry->title|escape}

But I can't figure out how to get the UDT to read that?

Instead of inserting language into the lang file.. is there a way to contain it in the UDT so that it does something like this:

Code:
if($result_next['cgblog_id']) {
$blogtitle = ($result_next['cgblog_title']);

and then some how get it to read like this:
Code:
$smarty->assign('cgblog_next_text', $blogtitle;


I am sure the way i wrote it is not correct.. i was simply trying to show you what i was trying to do...


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links?
PostPosted: Fri Sep 02, 2011 5:49 am 
Offline
Forum Members
Forum Members

Joined: Mon Feb 21, 2011 2:08 am
Posts: 50
Got IT!

I added this into your UDT:
Code:
$blogtitle = $result_prev['cgblog_title'];

then I changed the language line to this:
Code:
$smarty->assign('cgblog_prev_text', $blogtitle);


did the same for the
"next" pieces of the code

On the image I added a ALT tag and a title tag with the {$cgblog_next_text} in it and now the image displays the blog title!

Thanks so much for your help!!


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links?
PostPosted: Fri Sep 02, 2011 5:55 am 
Offline
Forum Members
Forum Members

Joined: Mon Feb 21, 2011 2:08 am
Posts: 50
Here is my finished UDT titled prev_next:
Code:
if (!function_exists('MyGetModuleInstance'))
{
        function &MyGetModuleInstance($module)
        {
                $gCms = cmsms();

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

$gCms = cmsms();
$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']) {
$blogtitlenext = $result_next['cgblog_title'];
$aliased_title = munge_string_to_url($result_next['cgblog_title']);
$prettyurl = 'blog/' . $result_next["cgblog_id"] ."/$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']) {
$blogtitle = $result_prev['cgblog_title'];
$aliased_title = munge_string_to_url($result_prev['cgblog_title']);
$prettyurl = 'blog/' . $result_prev["cgblog_id"] ."/$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', $blogtitlenext);
$smarty->assign('cgblog_prev_url', $prev_uri);
$smarty->assign('cgblog_prev_text', $blogtitle);


And here is the code I did for the images to display:
Code:
<p style="text-align: center;"> </p>
{prev_next pageid=$page_id currid=$entry->id currdate=$entry->postdate}
<table style="width: 99%;" border="0" align="center">
<tbody>
<tr>
<td style="width: 25%;">{if $cgblog_prev_url}<a href="{$cgblog_prev_url}"><img src="uploads/images/back.png" alt="{$cgblog_prev_text}" title="{$cgblog_prev_text}" width="128" height="128" /></a>{/if}</td>
<td style="width: 25%;" align="right">{if $cgblog_next_url}<a href="{$cgblog_next_url}"><img src="uploads/images/next.png" alt="{$cgblog_next_text}" title="{$cgblog_next_text}" width="128" height="128" /></a>{/if}</td>
</tr>
</tbody>
</table>
<p style="text-align: center;"> </p>


Works like a charm!!!


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links? [SOLVED]
PostPosted: Tue Oct 25, 2011 6:27 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 481
Location: Florida
Help! If you can, pretty please, this doesn't work with Version 1.10 of CMSMS


Code:
Fatal error: Call to a member function GetRow() on a non-object in /home/username/public_html/domainname/subdirec/lib/classes/class.usertagoperations.inc.php(260) : eval()'d code on line 33


Code:
$gCms


According to the upgrade notes on the home page of CMSMS, the above doesn't work any longer. Since I'm no programmer, I don't know what to do.

This is what CalGuy wrote:
Note arrows and various elements on his notes are gone, look at the source: [url]http://www.cmsmadesimple.org/2011/10/Announcing-CMS-Made-Simple-1-10/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+cmsmadesimple%2Fblog+%28CMS+Made+Simple%29
[/url]
Code:
What We Broke (Technical Stuff):

1: Removing $gCms→smarty, use cmsms()→GetSmarty() instead.
In older versions of CMSMS the $gCms object contained a reference to the global smarty object. The global smarty object is now a singleton to ensure that it cannot be instantiated more than once.

2: Removed the $gCms→config, use cmsms()→GetConfig() instead.
Similar to the Smarty object, the config object is also a singleton. Therefore that method of accessing the config object has been removed.

3: Removed the $gCms→modules array. use cms_utils::get_module() instead.
The public modules array, a throwback to the days of php4 has been removed, and replaced with a complete api (see the ModuleOperations class). A simple method to obtain a module object reference has been (since CMSMS 1.9) the cms_utils::get_module() method. This may effect your UDT’s the most.

4: Revised the content objects
In CMSMS 1.10, as the first step in revising our object interface for the sake of efficiency we have revised the Content object to ensure that all member variables are private and that accessors exist for each data member. The most prominent of these is the ‘mModifiedDate’ member of the content object, which was public but had no accessor method.

5: The CmsObject class is now final and a singleton.
In CMSMS 1.10, the CmsObject class (aka the $gCms variable) is now a final, non-extendable class.

6: Removed deprecated callbacks from the module api.
The last of the long deprecated callbacks were removed from the module class as they have been replaced by events for a long time.

7: Private, Protected, and final methods in the module API.
Our first step in the cleanup of the module API was to clean up the interfaces for this class. We have declared most methods to be public or protected. Some methods are also final and cannot be overridden. We have also deprecated the Redirect methods of the module API.

8: Replaced, but deprecated some members of the module class.
The smarty, db, and config members of the module class (which were references to the global versions of those objects) have been removed, and replaced with access methods. Though this should not break compatibility the following is now deprecated:

$this→smarty – when $smarty is not provided to you in scope, you should use cmsms()→GetSmarty()
$this→db – when $db not provided to you in scope, you should use cmsms()→GetDb();
$this→config – you should use cmsms()→GetConfig();
$this→cms – When not provided in scope, you should use $gCms = cmsms();


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links? [SOLVED]
PostPosted: Tue Oct 25, 2011 6:41 pm 
Offline
Forum Members
Forum Members

Joined: Mon Feb 21, 2011 2:08 am
Posts: 50
carasmo wrote:
Help! If you can, pretty please, this doesn't work with Version 1.10 of CMSMS


Sorry I didn't upgrade to 1.10 specifically because of a lot of the items that haven't been updated yet, so unfortunately I have no idea of if or even how to make it work....


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links? [SOLVED]
PostPosted: Tue Oct 25, 2011 8:35 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 481
Location: Florida
Good plan! I did a complete backup and made a sub directory linked up the database, made sure that 1.9.43 or whatever the last latest one worked smoothly, then did the upgrade, YIKES! Cataloger, Advanced Content, so many issues, no feedcontent except title (summarize tag is not supported but truncate is). I did get this UDT updated by the CalGuy himself and it works! But so many other things don't, so I'm going back to the old install:

Code:
// nuked all the stuff above here.
$gCms = cmsms();
$db = cmsms()->GetDb();    // changed this line.
$cgblog = cms_utils::get_module('CGBlog');  // changed this line.

$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"));


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links? [SOLVED]
PostPosted: Tue Oct 25, 2011 9:25 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 6585
Location: Fernie British Columbia, Canada
I'll prolly release Cataloger this week. SjG is just too busy, so I volunteered to do it.

I Don't recommend using AdvancedContent anyways...

CGSimpleSmarty was released today.

_________________
Follow me on twitter
--
if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: CGBlog - Next/Previous Links? [SOLVED]
PostPosted: Tue Oct 25, 2011 9:41 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 481
Location: Florida
Thank you CalGuy/Robert. I switched all the stuff to regular content blocks and with a 1 or 0 and it works faster than AdvancedContent. I did did that thing, drop menus, checkboxes, etc.,


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

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