Drupal taxonomy views override path for specific content - drupal-7

I am beginning to be a little desperate here. I have following structure (Drupal 7):
I use taxonomy menu to build menu links,
The taxonomy_term default (page) view is used to override drupal's taxonomy/term/% path
In addition to it I use menu_block module (but I doubt that this is important). What I am trying to achieve:
I need to build node browser by category (taxonomy term) but it has exceptions - for example taxonomy term with id 850 (taxonomy/term/850) must have different content structure than other therms. Is it possible to override default views display with these exceptions? I tryied to create another display with this path but the result was "not found". I also thought on using blocks not page displays, yet this solutions does not seem to be the Drupal way to me.

I was facing the same problem while trying to have different display/structure for publications in contrast to normal articles.
What I did, created a separate view for that specific taxonomy such as taxonomy/term/850, and in the path in view I entered 'taxonomy/term/850' (in this case)
This caused it override taxonomy/term/%
and displayed it differently according to my need.

Related

Wagtail Page create via model_mommy

I'm trying to create some tests for my first Django site. One thing that is burdensome is creating example pages for testing (at least you have to specify a lot of parameters and some (such as ContentType) are not always obvious. More generally, I'd like to use Model Mommy to create many of the objects I need.
Near as I can tell, it can't create an instance of a Page (claiming that a "Page matching query does not exist"). [the test case is a simple import of Page and Model Mommy then create an instance of a page].
I'm not sure if this is properly an issue for Wagtail or for Model Mommy, but debugging it is getting a bit out of my depth and it would be very useful if it could work.
Unless there is something obvious I'm missing or can/should do, I'm posting this more to flag the problem than to try to get a solution right now.
Thx,
--Don
Mommy doesn't handle Django Tree Beard relations. Tree Beard is the package used by Wagtail to create the page tree.
Mommy doesn't create the tree structure correctly. You should add your pages to the tree yourself. You can do this with add_child.
Root is created by the Wagtail migrations: https://github.com/wagtail/wagtail/blob/master/wagtail/core/migrations/0002_initial_data.py#L13-L38
There is no need to set the content type manually if you use your specific class directly. I used FooPage in the example below.
from wagtail.wagtailcore.models import Page
from app.models import FooPage
root = Page.objects.get(slug='root')
page = FooPage(title='Example', ...)
root.add_child(instance=page)

Create Landing Page in Drupal 7

In Drupal one can basically style the elements, like the search box, or the basic page etc. and then put some content in the site and the resulting page will be generated. But what if you want one specific site (e.g. the index page) to be different? E.g. have a image as a background, a different navigation styling etc.
What's the best paractice way of doing this?
Best practice is to have a different theme which you can switch to by using hook_custom_theme() where you check the current path. Also make sure that your theme to switch to is enabled:
/**
* Implements hook_custom_theme().
*/
function YOUR_MODULE_custom_theme() {
# check path with arg(0)
# return theme name to switch to
return 'different_theme_machine_name';
}
Alternatively you can also try ThemeKey doing this out of the box with an interface & allowing you the specify rules.
If you need to change only the content(body) section of your page, use Disply Suite. You can create unique look and feel layouts for your body section of each page.
If you trying to change the complete layout of one page (eg: Services), Create new Content Type 'Services'. Then create a template file for this content type, You must name this template call page--services.tpl.php. And also you can overwrite the index page layout by creating page--front.tpl.php template. Done!
What you are saying you want to change is all styling. And you know you can do a page to look drastically different with CSS... and you can do it that way depending on your chosen Drupal theme.
Now, with the Chrome Inspector (or FF inspector) look at the body tag, it probably has many classes which indicates in what page you are, what type of node (if it's a node) or if it's an admin section, or an anonymous user.
Using those specific classes you can style a frontpage, or a view, or a node, or anything, without installing more modules... with some limitations because you can't change rendered HTML this way.
Finally, don't get scared by using modules in Drupal, it's how Drupal works and it works pretty well. The thing is to install the best tools to increase your productivity, and Drupal have excellent options to change your theming and content like Display Suite (like #BaikHo suggested).
Hope that helps.
PD: Using the less module and with custom your theme you can have LESS css which is considerably faster than using only CSS, and because it's integrated with Drupal you can theme make everything even faster. Give it a try.

Joomla modules do not show up when accessing the page from a link

In Joomla I have the following situation:
I have an article (a page) that i declared in articles, the "products page". I did not enter any text or html in it.
I went to Module Manager and declared 3 modules (with text and html inside). The 3 modules are describing the 3 products that the company offers. Also I set the 3 modules to be placed in specific places (POSITIONS). I am using Gantry as a template, and the positions for the 3 modules are utility-a, utility-b and utility-c.
In each module, I chose the menu assignment, so that the modules will be shown in a specific page: the products page.
In MainMenu, I have a menu Item called "Products" that points to the empty article and is: index.php?option=com_content&view=article&id=2. Also in this menu item, I checked the Module Assignment, to see if the utility modules are shown and yes, they appear as "Display:yes"
NOW: When I access the "products page" from the main menu, the page shows up and contains the 3 utility modules, so everything is ok. But if I want to access this product page from a (manual)link (a href with the src above) inside a different page, then the product page shows up empty, like there is nothing on the page. I mean those utility modules do not show up. Only the empty article is shown.
How can I make the modules to show up?
Thank you
I solved it. I had to make a manual change to the link used as src. I had to add &Itemid=yyy at the end of the page link, and the yyy is the ID.
The useful documentation is here: http://docs.joomla.org/How_to_control_module_display_when_linking_to_an_article_with_no_menu_item
Thank you. Problem solved

Drupal 7 : How to show specific block in a particular view

I want to display particular block on view page. I have added list to show specific view in a particular block as <viewpagename>, but it is not working. How can I show a particular block on a particular view page in Drupal 7?
Long time I didn't touch Drupal, however, if I remember right, after you choose a path for your view, you can add that path to the settings of the block.
so if the view is available on /view-page, add to the block setting "view-page" in the "include" section.
There is a block_views module made specifically for this reason I believe. It's in beta but works rather nicely for Drupal 7:
https://drupal.org/project/block_views
Cheers,
-cs

Drupal: D7 rewriting values returned by views

I have a requirement to perform an indexed search across content which must include a couple of tags in the result. The tags must be a random selection. The platform is Drupal 7.12
I have created a view that manages the results of a SOLR search through the search_api. The view returns the required content and seems to work as intended. I have included a couple of Global: custom text fields as placeholders for the tag entries.
I am now looking for a solution to manage the requirement to randomise the tag values. The randomisation is not the issue, the issue is how to include the random values into the view result.
My current approach is to write a views_pre_render hook to intercept the placeholders which appear as fields ([nothing] and [nothing_1]). The test code looks like the following
function MODULE_views_pre_render( &$view )
{
$view_display = $view->display['default'];
$display_option = $view_display->display_options;
$fields = $display_option['fields'];
foreach( $view->result as $result )
{
$fields['nothing']['alter']['text'] = sprintf("test %d", rand(1,9));
}
}
I am currently not seeing any change in the placeholder when the view is rendered.
Any pointers to approach, alternate solutions etc would be gratefully received as this is consuming a lot of scarce time at the moment. Calling print_r( $view ) from within the hook dumps over 46M into a log file for a result set of 2 items.
There are two possible solutions for your task.
First approach is do everything on the template level. Define a template for the view field you want to randomize. In advanced settings of your display go to Theme: Information. Make sure that the proper theme is selected and find the template suggestions for your field. They are listed starting from most general to the most specific and you can choose whatever suits you better.
I guess the most specific template suggestion for your field would be something like this: views-view-field--[YOR VIEW NAME]--[YOUR DISPLAY NAME]--nothing.tpl.php. Create the file with that name in the theme templates directory and in this template you can render what ever you want.
By default this template has only one line:
print $output;
you can change this to:
print sprintf("test %d", rand(1,9));
or to anything else, whatsoever :)
Second approach is to go with Views PHP module. WIth this module you can add a custom PHP field in which you can do whatever you want. Even though the module hasn't been released it seems to work quite well for the most of the tasks and most certainly for such a simple task as randomizing numbers it will work out for sure.
I stumbled upon this while searching for another issue and thought I would contribute.
Instead of adding another module or modifying a template, just add a views "sort criteria" of "Global: Random".

Resources