Tag that produces link to a blog article?
Tag that produces link to a blog article?
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:
Re: Tag that produces link to a blog article?
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
. it may not follow best practice but hasnt failed yet{BlogLink id=23 text='optional alternative text'}
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

- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Tag that produces link to a blog article?
{cms_action_url module=CGBlog action=detail articleid=5}
will generate a URL to the specified blog article.
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.
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.
Re: Tag that produces link to a blog article?
And you can simplify it for the editors with:calguy1000 wrote:{cms_action_url module=CGBlog action=detail articleid=5}
will generate a URL to the specified blog article.
https://www.cmscanbesimple.org/blog/cal ... from-a-udt
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -


