PDA

View Full Version : [CMS] Add thread link to article preview


emperatour
01-23-2011, 11:47 AM
Hi,

In vB4 CMS, in order to reach the promoted forum posts we have to open the article and click on the tiny url at the end of each article (vbcms_content_article_page):
https://vborg.vbsupport.ru/attachment.php?attachmentid=125980&stc=1&d=1295789254


I would like have the same thing in my article preview (cms home page) for each of the articles.

I found the codes in template "vbcms_content_article_page" which is for this part of articles.
<vb:if condition="$promoted_threadid">
<div class="fullsize article_promoted_text_container">
<sub class="article_promoted_text">
{vb:rawphrase promoted_post_intro}
<a href="{vb:link thread, {vb:raw threadinfo}}">{vb:raw postitle}</a>
{vb:rawphrase promoted_thread_startedby}
<a href="{vb:link member, {vb:raw poststarter}}">{vb:var postauthor}</a>
</sub>

<sub class="article_promoted_text">
<a href="{vb:raw post_url}">{vb:rawphrase view_original_post}</a>
</sub>
</div>
</vb:if>

But somehow I can't use some of variables in template "vbcms_content_article_preview".
vb:link thread
vb:raw threadinfo
vb:link member
vb:raw poststarter
vb:raw post_url
These variables are not accessible from "vbcms_content_article_preview" template. However I only need vb:raw post_url to get the url and $promoted_threadid to get the condition.

This is what I get in CMS home page (vbcms_content_article_preview):
https://vborg.vbsupport.ru/attachment.php?attachmentid=125981&stc=1&d=1295789254

I really need to have thread links in article preview in my CMS. I would appreciate your help.

thanks in advance,

Lynne
01-23-2011, 05:29 PM
You need a plugin to get the thread id, I believe. Something like (at vbcsm_article_populate_end):
$record = vB::$vbulletin->db->query_first("SELECT a.threadid
FROM " . TABLE_PREFIX . "cms_article AS a
JOIN " . TABLE_PREFIX . "cms_node ON(cms_node.contentid = a.contentid)
WHERE nodeid = " . $this->getNodeId());

$view->threadid = $record['threadid'];Now you can use the threadid to make a link in the template.

thieu.bocap
01-24-2011, 08:01 AM
You need a plugin to get the thread id, I believe. Something like (at vbcsm_article_populate_end):
$record = vB::$vbulletin->db->query_first("SELECT a.threadid
FROM " . TABLE_PREFIX . "cms_article AS a JOIN cms_node ON(cms_node.contentid = a.contentid) WHERE nodeid = " . $this->getNodeId());

$view->threadid = $record['threadid'];
Now you can use the threadid to make a link in the template.

Sorry, you can more detailed instructions, i need too!

Thanks!

emperatour
01-24-2011, 09:55 AM
Thanks a lot Lynne for your answer,

When I add this as a plugin in hook location vbcms_article_populate_end i get the following db error:

Database error in vBulletin 4.1.1:

Invalid SQL:
SELECT a.threadid
FROM vbt_cms_article AS a JOIN cms_node ON(cms_node.contentid = a.contentid) WHERE nodeid = 174;

MySQL Error : Table 'myhostusername_vbulletin.cms_node' doesn't exist
Error Number : 1146
Script : http://..../forum/content.php

Product: vBulletin or vBulletin CMS
Execution Order: 5

I appreciate if you tell me the correct way to do this.

Lynne
01-24-2011, 04:44 PM
Then add the prefix in front of the other table name also:
$record = vB::$vbulletin->db->query_first("SELECT a.threadid
FROM " . TABLE_PREFIX . "cms_article AS a
JOIN " . TABLE_PREFIX . "cms_node ON(cms_node.contentid = a.contentid)
WHERE nodeid = " . $this->getNodeId());

$view->threadid = $record['threadid'];

emperatour
01-25-2011, 03:50 AM
I successfully created the plugin after adding another prefix for cms_node.
This will be the correct codes which I used:
$record = vB::$vbulletin->db->query_first("SELECT a.threadid
FROM " . TABLE_PREFIX . "cms_article AS a
JOIN " . TABLE_PREFIX . "cms_node ON(" . TABLE_PREFIX . "cms_node.contentid = a.contentid)
WHERE nodeid = " . $this->getNodeId());

$view->threadid = $record['threadid'];

In case someone else want to know, I used threadid in templates in this format: {vb:raw threadid}

I truly appreciate your help Lynne.
regards,

Phoebes
07-15-2011, 06:43 PM
I was looking to do this same thing.
I followed what you did here and I can get it to link to the correct post by using something like:

<a href="showthread.php?{vb:raw threadid}">{vb:raw title}</a>

but, is there a way to get the link to have the search engine friendly appended title text to the end of the link?
Instead of the link looking like ...showthread.php?37. it would look like ...showthread.php?37-title-text-here

Lynne
07-15-2011, 10:22 PM
There is an article on writing the friendly urls correctly here - vBulletin 4 Template Syntax: Links (https://vborg.vbsupport.ru/showthread.php?t=221572)

Phoebes
07-16-2011, 01:23 AM
Thanks for the link Lynne, but It's not working for me still.


Is



$record = vB::$vbulletin->db->query_first("SELECT a.threadid
FROM " . TABLE_PREFIX . "cms_article AS a
JOIN " . TABLE_PREFIX . "cms_node ON(" . TABLE_PREFIX . "cms_node.contentid = a.contentid)
WHERE nodeid = " . $this->getNodeId());

$view->threadid = $record['threadid'];



enough to give the vbcms_content_article_preview template access to the title information? The only thing I can generate is the thread id. Is there another query I need to add to get the title? If so, I'm not sure of the syntax for that.

hoangserip
09-23-2014, 07:27 AM
Thanks for Lynne, I also have problems with friendly urls, hope you can help me complete

ozzy47
09-23-2014, 09:39 AM
Thanks for Lynne, I also have problems with friendly urls, hope you can help me complete

This thread is three years old, you need to start your own thread, and provide more information. " I also have problems with friendly urls " is not very descriptive.:)