Last updated December 26, 2008. Created by yurtboy on December 26, 2008.
Log in to edit this page.
I wanted to make a quick tab where the user could go to My Account and see My Content.
I think there is a module to do this but I could not find it so I made a View (you will of course need this module for this to work)
Now when the user goes to My Account they see an extra tab called My Content which shows nodes authored by them. And the title field as well as the Edit field.
Here is the View Code you can import
$view = new view;
$view->name = 'my_content';
$view->description = 'users content';
$view->tag = 'Users';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'title' => array(
'label' => 'Title',
'link_to_node' => 0,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'edit_node' => array(
'id' => 'edit_node',
'table' => 'node',
'field' => 'edit_node',
),
));
$handler->override_option('arguments', array(
'uid' => array(
'default_action' => 'empty',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'uid',
'table' => 'users',
'field' => 'uid',
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'blog' => 0,
'poll' => 0,
'forum' => 0,
'panel' => 0,
'book' => 0,
'ecobytes' => 0,
'event' => 0,
'faq' => 0,
'incentive' => 0,
'job_notice' => 0,
'office_docs' => 0,
'page' => 0,
'press_release' => 0,
'program' => 0,
'resource' => 0,
'solutions' => 0,
'staff_help' => 0,
'story' => 0,
'support_request' => 0,
'tips' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'3' => 0,
'1' => 0,
'9' => 0,
'2' => 0,
'5' => 0,
'4' => 0,
'8' => 0,
'7' => 0,
'6' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_php' => '',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('title', 'My Content');
$handler->override_option('empty', 'Oops you have not content...');
$handler->override_option('empty_format', '2');
$handler->override_option('items_per_page', 100);
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'title' => 'title',
'edit_node' => 'edit_node',
),
'info' => array(
'title' => array(
'sortable' => 1,
'separator' => '',
),
'edit_node' => array(
'separator' => '',
),
),
'default' => '-1',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'user/%/mycontent');
$handler->override_option('menu', array(
'type' => 'tab',
'title' => 'My Content',
'weight' => '6',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => '0',
));
Comments
where do I place this code?
Thanks for the code! Now a silly question from someone who doesn't know any coding. Where do I copy this code to? Can someone please help!
http://www.your-domain.com/ad
http://www.your-domain.com/admin/build/views/import
not working
Thanks .. the view works perfectly!
Regards,
Sumaiya Javed
Web Developer
www.sumaiyajaved.com
www.phpjavascript.com
can't enter this code in the location indicated
when I go to mydomain.com/admin/build/views/import I just get a "404 Not found". Can I enter it anywhere via my website's "file manager" on my hosts' server?
use your own domain name
substitute your domain name for "mydomain.com" and you'll be good to go
... said to the Captain, please bring me my wine...