How can I go about adding the newest added product to the home page. I want to make the last product added appear as a featured item. This way, the home page stays fresh. I'm at a loss of how to approach this. The home page is a completely custom layout using page-front.tpl.php.
List newest product on home page as 'featured item'?
|
|
I would use views to make a block showing the latest products. I am not sure if this would work with your theme or not?
Views can be put into blocks, so if your page-front.tpl.php has regions for it to go in, it can be displayed there. Alternatively, if you want this view to be in the main content, set up a URL for the view as a page, and set that URL to be the front page.
Hi there,
I've done this with the Views module and the Views bonus pack module. Here's the exported code for the View
$view = new stdClass();
$view->name = 'newest_items';
$view->description = 'Newest Items';
$view->access = array (
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = 'Newest Items';
$view->page_header = '';
$view->page_header_format = '1';
$view->page_footer = '';
$view->page_footer_format = '1';
$view->page_empty = '';
$view->page_empty_format = '1';
$view->page_type = 'bonus_grid';
$view->url = 'Newest_Items';
$view->use_pager = TRUE;
$view->nodes_per_page = '12';
$view->block = TRUE;
$view->block_title = 'Newest Items';
$view->block_header = '';
$view->block_header_format = '1';
$view->block_footer = '';
$view->block_footer_format = '1';
$view->block_empty = '';
$view->block_empty_format = '1';
$view->block_type = 'bonus_grid';
$view->nodes_per_block = '3';
$view->block_more = TRUE;
$view->block_use_page_header = FALSE;
$view->block_use_page_footer = FALSE;
$view->block_use_page_empty = FALSE;
$view->sort = array (
array (
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
$view->argument = array (
);
$view->field = array (
array (
'tablename' => 'node',
'field' => 'title',
'label' => '',
'handler' => 'views_handler_field_nodelink',
'sortable' => '1',
'options' => 'link',
),
array (
'tablename' => 'node_data_field_image_cache',
'field' => 'field_image_cache_fid',
'label' => '',
'handler' => 'content_views_field_handler_ungroup',
'options' => 'product_list_linked',
),
array (
'tablename' => 'uc_products',
'field' => 'sell_price',
'label' => '',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'status',
'operator' => '=',
'options' => '',
'value' => '1',
),
array (
'tablename' => 'uc_products',
'field' => 'is_product',
'operator' => '=',
'options' => '',
'value' => '1',
),
);
$view->exposed_filter = array (
);
$view->requires = array(node, node_data_field_image_cache, uc_products);
$views[$view->name] = $view;Right now I've got it so that a block appears on the front page containing the newest 3 items and it has a link to a page to show more of the newest items. If you want you can disable the page.
Hope this helps
Hope this helps
I'm sure it would if I knew what I was doing.
2 weeks of Drupal and I'm still scratching my head here.
How would I go about using an exported view? If someone could just point me in the right direction, I'd appreciate it.
I've managed to create a view via the drupal admin interface, but skinning the appearance seems to be a different challenge. I assume if I could tap into the exported view object, I could control the final appearance as needed. Not sure what to do with the export, though...
Hi there,
Don't worry I'm in the same boat. Basically I installed the Views module and the Views bonus pack module.
Then go to the create a view place in your admin area and choose the import tab. Just enter the code I pasted in there and it should create a view for you using the settings in the code.
I think that's right....I'm no expert myself...lol
|
|





Joined: 04/08/2008