Drupal 7 views_embed_view and templates - php

In Drupal 7
created a block view (called *super_gallery*) of grid format
added a template specialization views-view-grid--super-gallery--block.tpl.php
cleared theme registry
cleared all caches
Using preview in view editor I can see output modified by the template. GOOD
Using <?php print views_embed_view("super_gallery", "default", $gallery_arguments); ?>
inside another template to show *super_gallery* view, it shows output without changes. BAD
How can I use templates with views_embed_view?
EDIT 1
Tried also with:
$view = views_get_view("super_gallery");
print $view->preview("default", $gallery_arguments);
and
$view = views_get_view("super_gallery");
print $view->execute_display("default", $gallery_arguments);
Nothing changed

Have you tried?
print views_embed_view("super_gallery", "block", $gallery_arguments);

Have a look at this module
http://drupal.org/project/embed_views
OR Have a look at the following comment
http://drupal.org/node/1138866#comment-4845070

Related

Drupal variables in region templates

I'm doing my first totally custom Drupal 7 theme. I have the page.tpl.php file working fine and have header and footer regions working, until I move this:
<?php print render($page['main_menu']); ?>
into region--header.tpl.php - the menu is no longer generated - the html around the PHP is generated - nav etc. so I know drupal's reading the template file OK.
The same code works fine if it is in page.tpl.php
Any help greatly appreciated.
Main menu available as block. So you can just put him to this region. It's good practice.
Also don't forget to clear drupal/browser cache.
If you define custom variable in preprocess_page() or any other preprocess functions you shouldn't use render function, just use print $main_menu for example.
Also try check this

joomla template on view=category

I make my own template , and its work well on www.90km2.com/index.php
But when I want to see com_content&view=category page on this link : http://www.90km2.com/index.php?option=com_content&view=category&id=23&Itemid=102
It doesn't work. Do you know why joomla didn't show my view?
I try another templates to see this page , all of them was worked well , but this view is not work with my own teplate :(
I would try copying the template which works then modify bit by bit to get your custom template then see when problem shows up. Or create a template which has the minimum stuff in there and see if it works. Just have jdoc:include type="component"/> in the body

Can't find Joomla pagination template

I'm going crazy with this one. I am trying to change a little bit the pagination style and layout in Joomla. So, I found this file: libraries\joomla\html\pagination.php but I know that pagination is overridden by this file: templates\gk_yourshop\html\pagination.php. Yet, if I modify something in gk_yourshop\html\pagination.php, I can't see the change in the pages. Does joomla cache templates and I have to re-load them (like phpBB)?. I don't understand.
I tried to check if writePagesLinks is called from joomla\html\pagination.php with this:
function getPagesLinks()
{
echo "test";
global $mainframe;
and I can't see the message. I also did this in the other pagination.php file and it's just like I can delete them and it doesn't matter. Can you help me? Thanks!
Looks like I changed it here some time ago:
\libraries\joomla\html\pagination.php
But, that is system file, so i just make a "hotfix" of it.
In Joomla 3.x you can create pagination override from Extensions > Templates > Default Template > Create Overrides > Layouts > Pagination.
The override files are created in "Default Template" "html\layouts\joomla\pagination" folder.
You can edit the override files as per your needs.
Where are you getting WritePageLinks from? That's not one of the supported methods.
http://docs.joomla.org/Understanding_Output_Overrides#Pagination_Links_Overrides
There are four functions that can be used:
pagination_list_footer
This function is responsible for showing the select list for the
number of items to display per page.
pagination_list_render
This function is responsible for showing the list of page number links
as well at the Start, End, Previous and Next links.
pagination_item_active
This function displays the links to other page numbers other than the
"current" page.
pagination_item_inactive
This function displays the current page number, usually not
hyperlinked.
[edit]
You may also want to look at Protostar as an example.

Customize a field output

I have a field named "field_enroll_link." I want to remove all the surrounding divs and just print the field content (it will go into the href of an anchor tag). I created the files "field--field_enroll_link-course.tpl.php" and "field--field-enroll-link-course.tpl.php," and put it into my template folder. It just contained <?php print render($item); ?>, but when I cleared the cached and even switched the themes, I'm still getting all the surrounding divs and markups. How do I override the field.tpl.php in Drupal 7?
In your theme's template.php file define this function and clear the cache. I am assuming you have devel module installed.
function your-theme_name_field($variables){
dsm($variables['items'][0]['#markup']);
return ;
}
You will be able to access the value you are looking for.

Drupal 6: assigning custom Display Output to views_embed_view

$viewName = 'my_view_name';
print views_embed_view($viewName);
we have such a cool views_embed_view func. in Drupal to display a view inside another template. But It doesn't get the custom "Display Output" :/ it gets the default.
How can I assign my custom Display Output (under Theme: Information) to views_embed_view?
Appreciate helps! thanks a lot!
[UPDATED]
I try as below, but still not taking the custom display
alt text http://files.droplr.com.s3.amazonaws.com/files/15306373/1hKd8R.view.jpg
$view = views_get_view('my_view_name');
$view->set_display('page_2'); // See gotcha below
$view->set_arguments($user->uid); // Set arguments
$view->pre_execute(array($user->uid)); // Set arguments for pre exicute
print $view->display_handler->preview();
$view->post_execute();
The gotcha is that page_2 is not the name of your display it is the views internal name, you can work this out by looking at the theme informaiton for the display you want in views admin.
You can just use
<?php print views_embed_view('my_view_name', 'block_1') ?>

Categories