Related
I have some issues adding a new tab in the backoffice menu.
I successfully created it with this function (called inside install method of module class):
public function createMenuTab() {
$tab = new Tab();
$tab->module = $this->name;
$tab->class_name = 'AdminQuote';
$tab->id_parent = 0;
$tab->active = 1;
foreach (Language::getLanguages(false) as $l)
$tab->name[$l['id_lang']] = 'Gestione Preventivi';
return (bool)$tab->add();
}
But now I don't know how to show a view.
I put the class AdminQuoteController in /controllers/admin/AdminQuote.php and it just extends ModuleAdminController.
What should I do now to show a view? I didn't find anything in the PS docs!
There is example from smartblog module.
<?php
class AdminImageTypeController extends ModuleAdminController
{
public function __construct()
{
$this->table = 'smart_blog_imagetype';
$this->className = 'BlogImageType';
$this->module = 'smartblog';
$this->lang = false;
$this->context = Context::getContext();
$this->bootstrap = true;
$this->fields_list = array(
'id_smart_blog_imagetype' => array(
'title' => $this->l('Id'),
'width' => 100,
'type' => 'text',
),
'type_name' => array(
'title' => $this->l('Type Name'),
'width' => 350,
'type' => 'text',
),
'width' => array(
'title' => $this->l('Width'),
'width' => 60,
'type' => 'text',
),
'height' => array(
'title' => $this->l('Height'),
'width' => 60,
'type' => 'text',
),
'type' => array(
'title' => $this->l('Type'),
'width' => 220,
'type' => 'text',
),
'active' => array(
'title' => $this->l('Status'),
'width' => 60,
'align' => 'center',
'active' => 'status',
'type' => 'bool',
'orderby' => false
)
);
parent::__construct();
}
public function renderForm()
{
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Blog Category'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Image Type Name'),
'name' => 'type_name',
'size' => 60,
'required' => true,
'desc' => $this->l('Enter Your Image Type Name Here'),
),
array(
'type' => 'text',
'label' => $this->l('width'),
'name' => 'width',
'size' => 15,
'required' => true,
'desc' => $this->l('Image height in px')
),
array(
'type' => 'text',
'label' => $this->l('Height'),
'name' => 'height',
'size' => 15,
'required' => true,
'desc' => $this->l('Image height in px')
),
array(
'type' => 'select',
'label' => $this->l('Type'),
'name' => 'type',
'required' => true,
'options' => array(
'query' => array(
array(
'id_option' => 'post',
'name' => 'Post'
),
array(
'id_option' => 'Category',
'name' => 'category'
),
array(
'id_option' => 'Author',
'name' => 'author'
)
),
'id' => 'id_option',
'name' => 'name'
)
),
array(
'type' => 'switch',
'label' => $this->l('Status'),
'name' => 'active',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'active',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active',
'value' => 0,
'label' => $this->l('Disabled')
)
)
)
),
'submit' => array(
'title' => $this->l('Save'),
)
);
if (!($BlogImageType = $this->loadObject(true)))
return;
$this->fields_form['submit'] = array(
'title' => $this->l('Save '),
);
return parent::renderForm();
}
public function renderList()
{
$this->addRowAction('edit');
$this->addRowAction('delete');
return parent::renderList();
}
public function initToolbar()
{
parent::initToolbar();
}
}
class BlogImageType extends ObjectModel
{
public $id_smart_blog_imagetype;
public $type_name;
public $width;
public $height;
public $type;
public $active = 1;
public static $definition = array(
'table' => 'smart_blog_imagetype',
'primary' => 'id_smart_blog_imagetype',
'multilang' => false,
'fields' => array(
'width' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'required' => true),
'height' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'required' => true),
'type_name' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true),
'type' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true),
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
),
);
.
.
.
}
Finally, I find this way:
I created the class AdminQuoteController in /controllers/admin/AdminQuote.php that extends ModuleAdminController. With this code inside:
class AdminQuoteController extends ModuleAdminController {
public function renderList() {
return $this->context->smarty->fetch(_PS_MODULE_DIR_.'preventivi/views/templates/admin/content.tpl');
}
}
This works even without declare display(), init(), initContent() or __construct() as I read in other previous threads.
I have a custom validator using $context that has been working for over a year.
The $context contains all posted parameters except for "bar" which is an empty array although it is posted as bar[0][description]. The array used to contain one or more arrays with key-value-pairs.
This seems to be the case since updating from version 2.3.2 to 2.5.1
I can't even check the 2.5 documentation since it's not available, Google didn't turn up anything close to the issue, ... was the behaviour changed or is this a bug?
Edit:
In .../Lorem/Form/FooForm.php I include a fieldset:
public function __construct() {
// ...
$this->add(array(
'type' => 'Collection',
'name' => 'bar',
'options' => array(
'label'=> '',
'count' => 1,
'should_create_template' => TRUE,
'allow_add' => TRUE,
'use_as_base_fieldset' => TRUE,
'target_element' => array(
'type' => 'Lorem\Fieldset\BarFieldset'
)
)
));
}
In .../Lorem/Fieldset/BarFieldset.php I have:
public function __construct() {
parent::__construct('bar');
$this->setHydrator(new ReflectionHydrator())
->setObject(new Bar());
$this->add(array(
'name' => 'description',
'type' => 'Textarea',
'attributes' => array(
'rows' => 3,
'cols' => 40,
),
));
$this->add(array(
'name' => 'amount',
'attributes' => array(
'type' => 'Text',
'class' => 'input-bar-amount',
'maxlength' => 9,
),
));
// ...
}
public function getInputFilterSpecification()
{
return array(
'description' => array(
'required' => TRUE,
'filters' => array(
array('name' => 'StripTags'),
),
'validators' => array(
array(
'name' => 'NotEmpty',
'break_chain_on_failure' => TRUE,
'options' => array(
'messages' => array(
'isEmpty' => 'Please enter a description.',
),
),
),
),
),
'amount' => array(
'required' => TRUE,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'NotEmpty',
'break_chain_on_failure' => TRUE,
'options' => array(
'messages' => array(
'isEmpty' => 'Please enter amount.',
),
),
),
array(
'name' => 'Float',
'break_chain_on_failure' => TRUE,
'options' => array(
'locale' => 'de',
'messages' => array(
'floatInvalid' => 'Invalid input. String, Integer oder Float expected.',
'notFloat' => 'Input ist not a floating point number.',
),
),
),
array(
'name' => 'Between',
'break_chain_on_failure' => TRUE,
'options' => array(
'min' => -1000000,
'max' => 1000000,
'messages' => array(
'notBetween' => "Only values between '%min%' and '%max%' EUR are allowed.",
'notBetweenStrict' => "Only values between '%min%' and '%max%' EUR are allowed.",
),
),
),
),
),
// ...
);
}
I have an array of behaviour $actas.Problem is when I adding date() function on the array string,it's return an error:
Example:
public $actas = array(
'Uploader.Attachment'=>array(
'books' => array(
'maxWidth' => 1200,
'maxHeight' => 1200,
'extension' => array('pdf'),
'nameCallback' => '',
'append' => '',
'prepend' => '',
'tempDir' => TMP,
'uploadDir' => '/var/www/html/apps/webroot/files/uploads/books' . date('d-m-Y'),//this is where I want to add the function.
'transportDir' => ''
)
)
);
however it's not working. I also do like this:
public $actas = array(
'Uploader.Attachment'=>array(
'books' => array(
'maxWidth' => 1200,
'maxHeight' => 1200,
'extension' => array('pdf'),
'nameCallback' => '',
'append' => '',
'prepend' => '',
'tempDir' => TMP,
'uploadDir' => "/var/www/html/apps/webroot/files/uploads/books'".date('d-m-Y')."'",//this is where I want to add the function.
'transportDir' => ''
)
)
);
also not worked.
So my question is how to do that? If I have a lot of mistaken,please tell me so I can learn more about the matter.
Thanks in advance.
This is the full source code of Post.php model
<?php
App::uses('AppModel', 'Model');
/**
* Post Model
*
* #property Tier $Tier
* #property Category $Category
* #property Comment $Comment
*/
class Post extends AppModel {
//var $now = 'CURDATE()';
/**
* Validation rules
*
* #var array
*/
public $validate = array(
'title' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'content' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
*
* #var array
*/
public $belongsTo = array(
'Tier' => array(
'className' => 'Tier',
'foreignKey' => 'tier_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Category' => array(
'className' => 'Category',
'foreignKey' => 'category_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
/**
* hasMany associations
*
* #var array
*/
public $hasMany = array(
'Comment' => array(
'className' => 'Comment',
'foreignKey' => 'post_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
public $actsAs = array(
//'Containable',
'Uploader.Attachment' => array(
// Do not copy all these settings, it's merely an example
'banner' => array(
'maxWidth' => 1200,
'maxHeight' => 1200,
'extension' => array('gif', 'jpg', 'png', 'jpeg'),
'nameCallback' => '',
'append' => '',
'prepend' => '',
'tempDir' => TMP,
'uploadDir' => "/var/www/html/apps/webroot/img/banners/",
'transportDir' => '',
'finalPath' => '/img/banners/',
'dbColumn' => '',
'metaColumns' => array(),
'defaultPath' => '',
'overwrite' => true,
'transforms' => array(),
'stopSave' => true,
'allowEmpty' => true,
'transformers' => array(),
'transport' => array(),
'transporters' => array(),
'curl' => array()
),
'feature' => array(
'maxWidth' => 1200,
'maxHeight' => 1200,
'extension' => array('gif', 'jpg', 'png', 'jpeg'),
'nameCallback' => '',
'append' => '',
'prepend' => '',
'tempDir' => TMP,
'uploadDir' => '/var/www/html/apps/webroot/img/features/',
'transportDir' => '',
'finalPath' => '/img/features/',
'dbColumn' => '',
'metaColumns' => array(),
'defaultPath' => '',
'overwrite' => true,
'transforms' => array(),
'stopSave' => true,
'allowEmpty' => true,
'transformers' => array(),
'transport' => array(),
'transporters' => array(),
'curl' => array()
),
'books' => array(
'maxWidth' => 1200,
'maxHeight' => 1200,
'extension' => array('pdf'),
'nameCallback' => '',
'append' => '',
'prepend' => '',
'tempDir' => TMP,
'uploadDir' => '/var/www/html/apps/webroot/files/uploads/books' . date('d-m-Y'),
'transportDir' => '',
'finalPath' => '/files/uploads/books/',
'dbColumn' => '',
'metaColumns' => array(),
'defaultPath' => '',
'overwrite' => true,
'transforms' => array(),
'stopSave' => true,
'allowEmpty' => true,
'transformers' => array(),
'transport' => array(),
'transporters' => array(),
'curl' => array()
)
)
);
}
ahh ok I was not looking at it with my OO hat on. you can't do this because:
Properties
Class member variables are called "properties". You may also see them
referred to using other terms such as "attributes" or "fields", but
for the purposes of this reference we will use "properties". They are
defined by using one of the keywords public, protected, or private,
followed by a normal variable declaration. This declaration may
include an initialization, but this initialization must be a
constant value--that is, it must be able to be evaluated at compile
time and must not depend on run-time information in order to be
evaluated.
you need to use the __construct() method
I have been building a module in PyroCMS and have made its structure. I am using Streams API to build forms and perform my actions and also performed a dummy install to check if everything looks ok. Then I went on modifying the contents of the dummy and completing my structure. However, in the details.php file, I made a change where I created a foreign key (relationship type of field, if u know the API jargon) to retrieve a field from another stream(the other stream being defined after my current stream) and now when I install the module, it shows 'Could not install the module' error, but I can see the module has been installed. I have tried to comment out the foreign key reference, but the problem still persists.
Here's my details.php file:
class Module_Employer extends Module
{
public $version = '1.0';
public function info()
{
return array(
'name' => array(
'en' => 'Employer'
),
'description' => array(
'en' => 'Module for Employer'
),
'frontend' => true,
'backend' => true,
'menu' => 'content',
'shortcuts' => array(
'create' => array(
'name' => 'Employer:new',
'uri' => 'admin/employer/create',
'class' => 'add'
)
)
);
}
public function install()
{
// We're using the streams API to
// do data setup.
$this->load->driver('Streams');
$this->load->language('employer/emp');
// Add streams
if ( ! $this->streams->streams->add_stream(lang('Employer:employers'), 'employers', 'employer', null, 'This is the Employer Stream')) return false;
if ( ! $this->streams->streams->add_stream(lang('Employer:company'), 'company', 'company', null, 'This is the Company Stream')) return false;
if ( ! $this->streams->streams->add_stream(lang('Employer:job'), 'jobs', 'job', null, 'This is the Job Stream')) return false;
// Fields for employers table
$employer_fields = array(
array(
'name' => 'Name',
'slug' => 'name',
'namespace' => 'employer',
'type' => 'text',
'extra' => array('max_length' => 100),
'assign' => 'employers',
'title_column' => true,
'required' => true,
'unique' => true
),
array(
'name' => 'Username',
'slug' => 'username',
'namespace' => 'employer',
'type' => 'text',
'extra' => array('max_length' => 100),
'assign' => 'employers',
'title_column' => true,
'required' => true,
'unique' => true
),
array(
'name' => 'Password',
'slug' => 'password',
'namespace' => 'employer',
'type' => 'encrypt',
'extra' => array('hide_typing' => 'yes'),
'assign' => 'employers',
'title_column' => true,
'required' => true,
'unique' => true
),
array(
'name' => 'Credits',
'slug' => 'credits',
'namespace' => 'employer',
'type' => 'integer',
'extra' => array('max_length' => 10),
'assign' => 'employers',
'title_column' => true,
'required' => true,
'unique' => true
),
array(
'name' => 'Company name',
'slug' => 'company_name',
'namespace' => 'employer',
'type' => 'relationship',
'extra' => array('choose_stream' => 'company'),
'assign' => 'employers',
'title_column' => true,
'required' => false,
'unique' => false
)
);
$this->streams->fields->add_fields($employer_fields);
//Fields for company stream
$company_fields = array(
array(
'name' => 'Username',
'slug' => 'username',
'namespace' => 'company',
'type' => 'relationship',
'extra' => array('choose_stream' => 'employers'),
'assign' => 'company',
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'E-mail',
'slug' => 'email',
'namespace' => 'company',
'type' => 'email',
'assign' => 'company',
'title_column' => true,
'required' => true,
'unique' => false
),
array(
'name' => 'Company Name',
'slug' => 'company_name',
'namespace' => 'company',
'type' => 'text',
'extra' => array('max_length' => 100),
'assign' => 'company',
'title_column' => true,
'required' => true,
'unique' => true
),
array(
'name' => 'Logo',
'slug' => 'logo',
'namespace' => 'company',
'type' => 'image',
'extra' => array('folder' => 'upload'),
'assign' => 'company',
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'Designation',
'slug' => 'designation',
'namespace' => 'company',
'type' => 'text',
'extra' => array('max_length' => 100),
'assign' => 'company',
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'Contact No.1',
'slug' => 'contact1',
'namespace' => 'company',
'type' => 'integer',
'extra' => array('max_length' => 10),
'assign' => 'company',
'title_column' => true,
'required' => true,
'unique' => false
),
array(
'name' => 'Contact No.2',
'slug' => 'contact2',
'namespace' => 'company',
'type' => 'integer',
'extra' => array('max_length' => 10),
'assign' => 'company',
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'Contact No.3',
'slug' => 'contact3',
'namespace' => 'company',
'type' => 'integer',
'extra' => array('max_length' => 10),
'assign' => 'company',
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'Address',
'slug' => 'address',
'namespace' => 'company',
'type' => 'textarea',
'assign' => 'company',
'title_column' => true,
'required' => true,
'unique' => false
),
array(
'name' => 'Billing ddress',
'slug' => 'billing_address',
'namespace' => 'company',
'type' => 'textarea',
'assign' => 'company',
'title_column' => true,
'required' => true,
'unique' => false
),
);
$this->streams->fields->add_fields($company_fields);
//Fields for company stream
$job_desc_fields = array(
array(
'name' => 'Username',
'slug' => 'username',
'namespace' => 'company',
'type' => 'relationship',
'extra' => array('choose_stream' => 'employers'),
'assign' => 'jobs',
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'Key Skills',
'slug' => 'keyskills',
'namespace' => 'company',
'type' => 'textarea',
'assign' => 'jobs',
'title_column' => true,
'required' => true,
'unique' => false
),
array(
'name' => 'Position Summary',
'slug' => 'position_summary',
'namespace' => 'company',
'type' => 'textarea',
'assign' => 'jobs',
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'Experience',
'slug' => 'experience',
'namespace' => 'company',
'type' => 'text',
'assign' => 'jobs',
'title_column' => true,
'required' => true,
'unique' => false
),
array(
'name' => 'Industry',
'slug' => 'industry',
'namespace' => 'company',
'type' => 'text',
'assign' => 'jobs',
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'Functional Area',
'slug' => 'functional_area',
'namespace' => 'company',
'type' => 'text',
'assign' => 'jobs',
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'Salary',
'slug' => 'salary',
'namespace' => 'company',
'type' => 'text',
'assign' => 'jobs',
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'Start Date',
'slug' => 'start_date',
'namespace' => 'company',
'type' => 'datetime',
'assign' => 'jobs',
'extra' => array('input_type' => 'datepicker'),
'title_column' => true,
'required' => false,
'unique' => false
),
array(
'name' => 'Job Type',
'slug' => 'job_type',
'namespace' => 'company',
'type' => 'choice',
'assign' => 'jobs',
'extra' => array('input_type' => 'datepicker'),
'title_column' => true,
'required' => false,
'unique' => false
),
);
return true;
}
public function uninstall()
{
$this->load->driver('Streams');
$this->streams->utilities->remove_namespace('employer');
return true;
}
public function upgrade($old_version)
{
// Your Upgrade Logic
return true;
}
public function help()
{
// Return a string containing help info
// You could include a file and return it here.
return "No documentation has been added for this module.<br />Contact the module developer for assistance.";
}
}
I had earlier "installed" the module, but under the uninstall() function, I forgot to add the code for removing all the streams(P.S: I had 3 streams with separate namespaces defined in the install() function). I only had the following:
$this->streams->utilities->remove_namespace('employer');
Due to this, the other streams were 'existing' in the system although on the face of it, the module was uninstalled, and whenever I tried to reinstall the module, I got the error Could not install module, since while creating tables/streams in the database, the query returned FALSE as the tables already existed.
However, I then added the code to remove all the other streams, by simply including their namespaces in the call for example:
$this->streams->utilities->remove_namespace('employer');
$this->streams->utilities->remove_namespace('job');
$this->streams->utilities->remove_namespace('company');
..and the problem was fixed!
I'm forking the filefield_stats module to provide it with the ability of exposing data into the Views module via the API.
The filefield_stats schema is as follow:
function filefield_stats_schema() {
$schema['filefield_stats'] = array(
'fields' => array(
'fid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary Key: the {files}.fid'),
'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary Key: the {node}.vid'),
'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'The {users}.uid of the downloader'),
'timestamp' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'The timestamp of the download'),
'hostname' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', 'description' => 'The hostname downloading the file (usually IP)'),
'referer' => array('type' => 'text', 'not null' => FALSE, 'description' => 'Referer for the download'),
),
'indexes' => array('fid_vid' => array('fid', 'vid')),
);
return $schema;
}
Well, so I implemented the hook_views_api() in filefield_stats.module & added a filefield_stats.views.inc file in the module's root directory, here it is:
// $Id$
/**
* #file
* Provide the ability of exposing data to Views2, for filefield_stats module.
*/
function filefield_stats_views_data() {
$data = array();
$data['filefield_stats']['table']['group'] = t('FilefieldStats');
// Referencing the {node_revisions} table.
$data['filefield_stats']['table']['join'] = array(
'node_revisions' => array(
'left_field' => 'vid',
'field' => 'vid',
),
'files' => array(
'left_field' => 'fid',
'field' => 'fid',
),
'users' => array(
'left_field' => 'uid',
'field' => 'uid',
),
);
// Introducing filefield_stats table fields to Views2.
// vid: The node's revision ID which wrapped the downloaded file
$data['filefield_stats']['vid'] = array(
'title' => t('Node revision ID'),
'help' => t('The node\'s revision ID which wrapped the downloaded file'),
'relationship' => array(
'base' => 'node_revisions',
'field' => 'vid',
'handler' => 'views_handler_relationship',
'label' => t('Node Revision Reference.'),
),
);
// uid: The ID of the user who downloaded the file.
$data['filefield_stats']['uid'] = array(
'title' => t('User ID'),
'help' => t('The ID of the user who downloaded the file.'),
'relationship' => array(
'base' => 'users',
'field' => 'uid',
'handler' => 'views_handler_relationship',
'label' => t('User Reference.'),
),
);
// fid: The ID of the downloaded file.
$data['filefield_stats']['fid'] = array(
'title' => t('File ID'),
'help' => t('The ID of the downloaded file.'),
'relationship' => array(
'base' => 'files',
'field' => 'fid',
'handler' => 'views_handler_relationship',
'label' => t('File Reference.'),
),
);
// hostname: The hostname which the file has been downloaded from.
$data['filefield_stats']['hostname'] = array(
'title' => t('The Hostname'),
'help' => t('The hostname which the file has been downloaded from.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
// referer: The referer address which the file download link has been triggered from.
$data['filefield_stats']['referer'] = array(
'title' => t('The Referer'),
'help' => t('The referer which the file download link has been triggered from.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
// timestamp: The time of the download.
$data['filefield_stats']['timestamp'] = array(
'title' => t('Download Time'),
'help' => t('The time of the download.'),
'field' => array(
'handler' => 'views_handler_field_date',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort_date',
),
'filter' => array(
'handler' => 'views_handler_filter_date',
),
);
return $data;
} // filefield_stats_views_data()
According to the Views2 documentations this should work as a minimum, I think. But it doesn't! Also there is no error of any kind, when I come through the views UI, there's nothing about filefield_stats data. Any idea?
I think your problem is in the function name: hook_views_data(), it should be filefield_stats_views_data().
hook_views_api() should also be filefield_stats_views_api().
You always replace hook with your module name when implementing them in your own modules.
Missing field definitions in the code above and also wrong hook_views_api() implementation. A working API implementation example can be found here: http://drupalcode.org/sandbox/sepehr/1073868.git/tree/refs/heads/master:/modules/sms_panel_views