Recent Topics

1 Oct 23, 2007 13:46    

My b2evo version: 1.10.2

Hi everybody,
I want to add a field in the post writing: the products_id of one product of my OSC shop.

I've been able to make the conection to the OSC db to get the list of my products and put that list in a dropdown just before the title field, in the writing area.

But I can't succeed to put the selected option value in the db.
What I've done:
in the blog/inc/MODEL/items/_items_class.php,[list]I've added the products_ID in the Object Definition:

'products_ID'	  => 'post_products_ID',


I've added the var declaration in the Item class:

var $products_ID;


And also in the insert function

var $products_ID;

,

$this->set( 'products_ID', $post_products_ID );

[/list:u]
But I'm missing something because when I try to save the post, I have this error message:

MySQL error!

Field 'post_products_ID' doesn't have a default value(Errno=1364)

Your query: DataObject::dbinsert()

INSERT INTO posts (post_creator_user_ID, post_datestart, post_notifications_status, post_renderers, post_status, post_locale, post_priority, post_main_cat_ID, post_ptyp_ID, post_url, post_urltitle, post_datedeadline, post_comment_status, post_content, post_wordcount, post_title, post_datecreated, post_datemodified, post_lastedit_user_ID)
VALUES ('1', '2007-10-23 13:31:43', 'noreq', 'b2evSmil.evo_lightbox.b2evALnk.evo_videoplug.b2WPAutP.evo_code.b2WPTxrz', 'draft', 'es-ES', '3', 1, 1, '', '100_jovencitas', NULL, 'o

So, as I can see, it doesn't get the information about the products_ID and that's why it gives me this error (this field in the db is not null)

The db field and the select input both name is [u]post_products_ID[/u].
I keep searching, but is anyone has a sugestion I'm very willing to read it.
thanks, cu

2 Oct 23, 2007 15:36

You don't need to hack the core to achieve this, you can add the field by using the AdminDisplayToolbar() event, and then use FilterItemContents() and UnFilterItemContents() to *add* the information to the post content ( we normally add them as a comment like <!--osc_product_id ## --> ).

¥

3 Oct 23, 2007 17:55

hi ¥åßßå,
thanx a lot for your time.
I'm very new to b2evo, so that information about how doing things in b2evo's way is very usefull to me.

I'm looking at these functions, but it's not talking a lot to me, for now. I got a few questions, if I may :)

1. all I see in the code about AdminDisplayToolbar is related to plugins: does that mean that I have to think about this issue as a plugin?
2. is there somewhere in the code of b2evo, or in any plugin you know something similar so I could see those functions in action?

thx again.

ps: I found this [url=http://forums.b2evolution.net/viewtopic.php?t=10042]thread[/url]: it seems that I have an answer to my first question...

4 Oct 23, 2007 17:59

the code_highlighter plugin makes use of all 3 events, it's probably a good start

¥

5 Oct 24, 2007 12:50

well, as I'm running out of time and I don't understand the way plugins are working (for now), I did it changing the code.
I'm sure it's not the best way to do it, but it's working.
Thanx again ¥åßßå for your time, and see you later.


Form is loading...