So this has been driving me crazy for 2 days, I have a module I've written that uses 3 DB tables, 2 of them install perfectly, and this is the third one:
$schema['tags_twistal'] = array(
'description' => t('Taxonomy for videos (tags)'),
'fields' => array(
'vid' => array(
'description' => t('The video ID'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'tag' => array(
'description' => t('The tag name'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
),
'primary key' => array('tag','vid'),
);
All I can think is that it has something to do with the primary key that I set, I've also tried:
'unique keys' => array(
'tag_vid' => array('tag', 'vid'),
),
'primary key' => array('tag_vid'),
Any ideas? I'm about to pull my hair out!
I'm having a similar issue in Drupal 7.
The tables of mine that install correctly are those which have a matching entry in the array returned by hook_node_info().
It looks as though Drupal will not create any tables that are not referenced in hook_node_info(), even if they are explicitly enumerated in hook_scheme(). I can't find this documented anywhere, but it matches my experience, and is a pain in the butt.
Related
I'm using CMB to creat custom fields for wordpress custom post
https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress
I'm using text_datetime_timestamp to set date and time and I need to make this field repeatable which is not
as I go through the documentation we can make new fields but I can't figure out how it make "text_datetime_timestamp" field repeatable
any body can show me the way to accomplish that ?
thank you
I did not find a solution to make the field repeatable so I put the field inside group and made it repeatable
array(
'id' => $prefix . 'repeat_date_group',
'type' => 'group',
'description' => '',
'options' => array(
'group_title' => __( 'Date/Time {#}', 'cmb' ),
'add_button' => __( 'Add Another Date/Time', 'cmb' ),
'remove_button' => __( 'Remove Date/Time', 'cmb' ),
'sortable' => true, // beta
),
'fields' => array(
array(
'name' => 'Date/Time',
'desc' => '',
'id' => $prefix . 'course_date',
'type' => 'text_datetime_timestamp'
),
),
),
I hope this answer will help somebody
Well here is my code, you may try this
$cmb= new_cmb2_box( array(
'id' => $prefix.'testing',
'title' => _('Testing'),
'object_types' => array('post'),
'context' => 'normal',
'priority' => 'high',
'show_names' => true,
));
$cmb->add_field( array(
'name' => 'Test Date/Time Picker Combo (UNIX timestamp)',
'id' => 'wiki_test_datetime_timestamp',
'type' => 'text_datetime_timestamp',
'repeatable' => true,
) );
im new on drupal and im having a problem with CCK fields.
I made a custom cck field and the install schema its like this:
function usig_location_field_schema($field) {
return array(
'columns' => array(
'location_cck_usig' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'lat_cck_usig' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'lon_cck_usig' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
),
);
}
But when i save the new content .. drupal crash with this log :
Fatal error: Cannot create references to/from string offsets nor
overloaded objects in /includes/common.inc on line 6392
So .. i know that im doing something wrong. I just dont know which hook use to save the fields.. (its possible save various fields at once ?)
Thx for all and sry for my english
You can always use this great module called Field Collection
Cheers
I'm creating a custom module which enables me to add Countries to a custom table in the database. I'll do later more with it, but as I got stuck at the beginning, I can't go on.
First my piece of code:
function partners_schema()
{
$schema['partners_country'] = array(
'description' => 'TODO: please describe this table!',
'fields' => array(
'id' => array(
'description' => 'auto inc id of country',
'type' => 'serial',
'not null' => true,
),
'name' => array(
'description' => 'name of country',
'type' => 'varchar',
'length' => '255',
'not null' => true,
'translatable' => true,
),
'needDistributor' => array(
'description' => 'is a distributor needed',
'type' => 'int',
'size' => 'tiny',
'not null' => true,
),
),
'primary key' => array('id'),
);
return $schema;
}
The code above generates my Database table. After searching I found that I can add 'translatable' => true to my schema, so Drupal knows that this field is translatable content.
I've added a form, to insert data into that schema, but now I got stuck. What do I have to do, that the user is able to translate the column name?
Thanks for your help.
Have a look at the accepted answer on this post it should help clear a few things up.
I am building my app and have been annoyed concerning sessions storage. I am a newbie about sessions. I am working with Symfony2 and MySQL, and as Symfony is storage-agnostic, I am searching into the Drupal 7 diagram to find a good model.
So I wondered a couple of things :
How to manage sessions in an Entity-Relationship diagram ?
In drupal 7 diagram, what do sessions->fields mean ?
Sessions -> uid (int(10)) -> OK
Sessions -> sid (varchar(128)) ?
Sessions -> ssid (varchar(128)) ?
Sessions -> hostname (varchar(128)) -> OK
Sessions -> timestamp (int(11)) -> guessing date of connection
Sessions -> cache (int(11)) -> Why only an integer ?
Sessions -> session (longblob) -> What do you put inside ?
As I imagined my own diagram, I had 2 tables :
Session that stored the sessionId, cookie and establishing date
User_Session, association between Sessions and Users, which stores IP address and DateInit.
Why not storing one session by Cookie and storing also each time the user connects ?
If someone could help me understand and help me find the true entity-relationship model...
Description of the session table from Drupal 7 is given in its system_schema() function:
$schema['sessions'] = array(
'description' => "Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.",
'fields' => array(
'uid' => array(
'description' => 'The {users}.uid corresponding to a session, or 0 for anonymous user.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'sid' => array(
'description' => "A session ID. The value is generated by Drupal's session handlers.",
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'ssid' => array(
'description' => "Secure session ID. The value is generated by Drupal's session handlers.",
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'hostname' => array(
'description' => 'The IP address that last used this session ID (sid).',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'timestamp' => array(
'description' => 'The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'cache' => array(
'description' => "The time of this user's last post. This is used when the site has specified a minimum_cache_lifetime. See cache_get().",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'session' => array(
'description' => 'The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
),
),
'primary key' => array(
'sid',
'ssid',
),
'indexes' => array(
'timestamp' => array('timestamp'),
'uid' => array('uid'),
'ssid' => array('ssid'),
),
'foreign keys' => array(
'session_user' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
);
But this is not an E-R model. Also, it heavily depends on Drupal own session handling function.
I am using Codeignitor's RPC to post to a wordpress blog which is working fine BUT I cannot get the custom fields working. I assume the custom_fields is not correct "wrapped up" for the call?
$thePost = array(array('title' => array('Aston','string'),
'description' => array('this is the description','string'),
'wp_author_id' => array('2','int'),
'mt_keywords' => array('personal finance, money management','string'),
'mt_text_more' => array('read more','string'),
'categories' => array(array('Small Business'),'array'),
'custom_fields' => array(array('key' => 'image','value' => 'Say Hello'),'struct')),
'struct');
$thePost = array(array('title' => array('Aston','string'),
'description' => array('this is the description','string'),
'wp_author_id' => array('2','int'),
'mt_keywords' => array('personal finance, money management','string'),
'mt_text_more' => array('read more','string'),
'categories' => array(array('Small Business'),'array'),
'custom_fields' => array(
array(
array(
'key' => 'your key',
'value' => 'value'
),
'struct')
),'struct')),
'struct');
Take a look at this thread http://wordpress.org/support/topic/add-custom-fields-to-a-post-using-xml-rpc
Basically it says that you should be using metaWeblog.newPost instead of the wp api.