How to add a new field to the CMS
by
22 Jan 2011
Rating: (2 votes
- 3.50 average)
- 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;
PHP Code:
$getFIELDNAME = vB::$vbulletin->db->query_first("SELECT FIELDNAME FROM " . TABLE_PREFIX . "cms_node WHERE nodeid = " . $this->nodeid);
3. Go to the template vbcms_edit_publisher. At the bottom of the template, before these lines: HTML Code:
</div> <div style="clear:both"></div> HTML Code:
<div class="blockrow" > <label class="thirdleft">FIELD TITLE</label> <div class="twothirdsright"><input type="text" size="30" value="{vb:raw FIELDNAME}" name="FIELDNAME" tabindex="1" class="textbox fullwidth" /></div> </div> Go to your ACP --> Plugins & Products --> Add New Plugin. Hook Location: vbcms_article_save_start. PHP Code: PHP Code:
vB::$vbulletin->input->clean_array_gpc('r', array(
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> PHP Code:
'imageheight', 'previewvideo', 'FIELDNAME'
PHP Code:
protected $FIELDNAME;
PHP Code:
public function getFIELDNAME()
PHP Code:
$view->FIELDNAME = $this->content->getFIELDNAME();
That's it, you're done. |