- Apply the changes mentioned in this how-to at your own risk.
- You must have a basic understanding of php, html and vbulletin.
- This is a how-to for vb4.1, and may not work on previous versions.
Everywhere you see FIELDNAME, replace it with your field name (must not contain spaces).
1.
Create a new field in the cms_node table.
2.
If you run vB 4.1.9 or lower , open packages\vbcms\item\content.php and find:
PHP Code:
return $pub_view;
Add above it:
PHP Code:
$getFIELDNAME = vB::$vbulletin->db->query_first("SELECT FIELDNAME FROM " . TABLE_PREFIX . "cms_node WHERE nodeid = " . $this->nodeid);
$pub_view->FIELDNAME = $getFIELDNAME['FIELDNAME'];
If you run 4.1.10+, you can just create a new plugin with the above code, the hook is vbcms_content_publish_editor.
3.
Go to the template vbcms_edit_publisher.
At the bottom of the template, before these lines:
vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_node SET FIELDNAME = '" . vB::$vbulletin->db->escape_string(vB::$vbulletin->GPC['FIELDNAME']) . "' WHERE nodeid = " . $this->content->getNodeId());
The following steps have been written by Lynne, thank you
5. To get the field to spit out, you must add it to the vbcms_content_article_page somewhere (this is rough, you'll have to add your own class/styling).
HTML Code:
<div>Custom Field:{vb:raw FIELDNAME}</div>
6. Then, open vbcms/item/content/article.php and add your field to the end of the protected $content_properties array.
PHP Code:
'imageheight', 'previewvideo', 'FIELDNAME'
7. In that same file, add this line with the other similar lines:
PHP Code:
protected $FIELDNAME;
8. Again, in the same file, add this with the other similar functions:
PHP Code:
public function getFIELDNAME()
{
$this->Load(self::INFO_CONTENT);
return $this->FIELDNAME;
}
9. Then add another plugin using hook_location "vbcms_article_populate_start":
1. edit isn't necessary => hook vbcms_content_publish_editor
2. template edit is fine, who cares about this ( tms^^ )
but everythng else seems to be impossible
shame that they still didn't change this
Yep, it took a year but they finally added the hook. I've updated the relevant step.
I guess I should have asked them to add some other hooks back then, cause if I open a new hook request now, vB 5 would be out by the time the hooks get added
Geez... I just spent almost an hour going through it and trying it out without any success.
Tsk, why does this have to be so darn complicated...
Hmm, how can I extend that $pub_view array to be available to other templates, not just vbcms_edit_publisher (as defined in content.php) in an easier manner...
--------------- Added [DATE]1295989658[/DATE] at [TIME]1295989658[/TIME] ---------------
It seems that I am having some issue with spitting out the value in the front-end as well... adding that code to vbcms_content_article_page prints out nothing.
Seems the root of the problem is $view->FIELDNAME = $this->content->getFIELDNAME(); in the plugin attached to vbcms_article_populate_start... as if I change that $view->FIELDNAME value to a constant, I get a value out on the front-end and in all the other templates (weird). If I leave it as $this->content->getFIELDNAME(), it ends up blank.
Having the same issue... $this->content->getFIELDNAME() seems like giving me blank too...