Tag that produces link to a blog article?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
postiffm
Forum Members
Forum Members
Posts: 128
Joined: Tue Nov 30, 2010 12:16 am

Tag that produces link to a blog article?

Post by postiffm »

Is there is a tag like {cms_selflink..." but that works with cgblog articles?" I'd like something like {cgbloglink page="blah" text="blah blah"} and it would produce a link like this:
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm

Re: Tag that produces link to a blog article?

Post by rotezecke »

I think the idea is to create a simple detailtemplate and call it with the articleid switch. a few years back i ran into a problem where i wanted to control the link text, hence i made this UDT I named BlogLink which I call like this
{BlogLink id=23 text='optional alternative text'}
. it may not follow best practice but hasnt failed yet

Code: Select all

if (isset($params['id'])) {
  $blog_ID = trim($params['id']);
  $blog_text = trim($params['text']);

  $db = cmsms()->GetDb();

  $query1 = "SELECT url,cgblog_title,status FROM ".cms_db_prefix()."module_cgblog WHERE cgblog_id = '$blog_ID'";
  $result1 = $db->Execute($query1);

  while ($result1 && $row = $result1->FetchRow()) {
        $url = $row['url'];
        $title = $row['cgblog_title'];
        $status = $row['status'];
   }

    //load config data
    $config = cmsms()->GetConfig();	
    //build the link how you like
    $url = $config['root_url'].'/my-cgblog-prefix/'.$blog_ID.'/'.$url.$config['page_extension'];

    if($blog_text =='') {
        $blog_text = $title;
     }
    //if article is active ->publish link, else text only.
    if($status =='published') {  echo "<a href='$url'>$blog_text</a>"; }
    else {     echo $blog_text; }
}
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Tag that produces link to a blog article?

Post by calguy1000 »

{cms_action_url module=CGBlog action=detail articleid=5}

will generate a URL to the specified blog article.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Tag that produces link to a blog article?

Post by Rolf »

calguy1000 wrote:{cms_action_url module=CGBlog action=detail articleid=5}

will generate a URL to the specified blog article.
And you can simplify it for the editors with:
https://www.cmscanbesimple.org/blog/cal ... from-a-udt
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Post Reply

Return to “Modules/Add-Ons”