Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
How to add a new field to the CMS
Yellow Slider
Join Date: Aug 2006
Posts: 249

 

Show Printable Version Email this Page Subscription
Yellow Slider Yellow Slider is offline 01-21-2011, 10:00 PM

- 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:
HTML Code:
</div>
<div style="clear:both"></div>
Add the following lines of code:
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>
4.
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(
    
'FIELDNAME' => TYPE_STR
));

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":
PHP Code:
$view->FIELDNAME $this->content->getFIELDNAME(); 
I think I got that all correct.


That's it, you're done.
Reply With Quote
  #12  
Old 02-04-2011, 08:32 AM
Miss T Miss T is offline
 
Join Date: Sep 2008
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hey Yellow

cant you please check you PM inbox - you qouta is up and the reply you asked me for cannot be sent to you
Reply With Quote
  #13  
Old 05-11-2011, 06:09 PM
edyy edyy is offline
 
Join Date: Jul 2010
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can't manage to make this to work, I've made everthing it says in here but when I put the data into the fields and push SAVE I get this error
Code:
Invalid SQL:
UPDATE for_cms_node 
SET url_prod = 'test1',
url_image = 'test2', 
WHERE nodeid = 21;

MySQL Error   : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE nodeid = 21' at line 4
Error Number  : 1064
Reply With Quote
  #14  
Old 05-11-2011, 07:22 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's because you have a comma right before the WHERE line which isn't supposed to be there.
Reply With Quote
  #15  
Old 05-12-2011, 01:30 PM
edyy edyy is offline
 
Join Date: Jul 2010
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem it is as you said a comma, thank you verry much for the help. Now i have the same problem as HouseAddict, the date is inserted into the database but is not spit out on the article page. Can you help me fix that problem too ?

Thanks again for the help.
Reply With Quote
  #16  
Old 05-12-2011, 09:57 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I haven't any need for adding a new field to my CMS, so I haven't looked into this in anyway past what I posted for Yellow Slider.
Reply With Quote
  #17  
Old 06-05-2011, 01:55 PM
edyy edyy is offline
 
Join Date: Jul 2010
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've tried the exact example and the date still isn't spit out in the article page.
Reply With Quote
  #18  
Old 04-11-2012, 11:32 AM
ohadpartuck ohadpartuck is offline
 
Join Date: Mar 2012
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi lynne,
I have the same problam,
I managed to save it but not to spit it out.
I didn't quiet understood number 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>

I have added <p>{vb:raw articlesource}</p>
and nothing..

any help?
Reply With Quote
  #19  
Old 05-03-2012, 08:47 AM
charlesr charlesr is offline
 
Join Date: Aug 2009
Posts: 177
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm desperate for custom article fields and ways to manage the CMS better - if this existed, it would make the CMS amazing. Currently I'd just describe the CMS as functional, albeit simple and easy to use.

Anyone else reading this thread, please vote and watch and comment here: http://tracker.vbulletin.com/browse/VBIV-10048

We have spent a lot of time making the VB4CMS look fantastic, and now just need it to BE fantastic! I can't spend time manually making new fields in the database - the long term implications are just too tricky.
Reply With Quote
  #20  
Old 05-03-2012, 02:26 PM
firebrand media firebrand media is offline
 
Join Date: Apr 2012
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
1.
Create a new field in cms_node
Off to a bad start since I don't even understand step 1.
Could someone explain?
Is this something I do in the control panel?
Do I need to create a plugin?
Modify a template?
Reply With Quote
  #21  
Old 05-03-2012, 02:55 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by firebrand media View Post
Off to a bad start since I don't even understand step 1.
Could someone explain?
Is this something I do in the control panel?
Do I need to create a plugin?
Modify a template?

These instructions involve manually modifying the database and editing vb files as well as template modifications and creating plugins. It took me a bit to understand that the first step is to add a column to the cms_node table in the database (could probably use some clarification there).
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:15 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08934 seconds
  • Memory Usage 2,327KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (3)bbcode_html
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (2)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete