What i want: Active terms of vocabulary in main menu.
What i have done so far:
I have used taxonomy_menu module.
Created taxonomy(Category).
Added "Status" field having boolean values (0 = Inactive, 1 = Active).
Added two terms in Category(Cat1 and Cat2).
Cat1 = Active, Cat2 = Inactive.
Configured menu from "Edit vocabulary" section.
Problem: All terms of vocabulary are included in main menu. I want that only those terms whose Status = Active should be displayed in main menu.
The process to make taxonomy_menu module aware of your status field seems hard to accomplish, particularly if you need - as you probably would - the taxonomy menu rebuilt when a status value changes.
A possibly easier solution would be to act at the theme level, adding a .inactive class to inactive items and make it hidden in css. Since Taxonomy Menu module does nothing about themeing, this should be dealt with with Menu module theme functions. So you'll end up writing a (e.g.) CUSTOM_menu_link() function in which you'll need to test if the link is coming from a taxonomy generated menu (not sure how you can do that, anyway) for every menu item of your site and then, if this is the case, load the term, test the status field and act accordingly. Not exactly an elegant solution, and quite an overhead.
If possible, I'd rather suggest you use the built-in feature to enable or disable menu items from the admin interface at admin/structure/menu/manage/main-menu, after configuring your taxonomy-menu.
Try this module:
https://www.drupal.org/project/termstatus
This module adds a status-flag to taxonomy terms. Using this flag it is possible to specify whether terms should be published or not. Users with the appropriate permission may access unpublished terms.
Related
How do I get the name of the pre test condition "Background" tag in a Feature using Specflow + Nunit in C #?
I can get the name of the "Feature" like this:
return FeatureContext.Current.FeatureInfo.Title;
And the name of the "Scenario" like this:
return ScenarioContext.Current.ScenarioInfo.Title;
I also need to get the name of the "Background", or check if it exists.
Feature: FeatureTest
Description Feature...
Background: Get Background name or check it exists (Return It)
...Given, And
Scenario: Scenario Test
...Given, And
TL;DR
The reason you can't access the Background, is because the steps contained within it are duplicated at runtime across all of the scenarios within a feature, effectively removing the background.
The Answer:
Generally speaking, Backgrounds do not have a title:
Ability: Adding and Removing items from the basket
As a customer,
I want the ability to add and remove items from my basket
In order to choose the items that I want to purchase from the site
Background:
Given I have logged in as a customer
And I visit the "Clothing" page
Scenario: Adding items to my basket
When I add "Black Jeans" to my basket in size "M"
Then the total should be "£9.99"
Scenario: Removing items from the basket
Given I have added an item of clothing to my basket
When I empty my basket
Then the total should be "£0.00"
The Background steps get duplicated across the scenarios within the feature, meaning that the scenarios in my example are effectively:
Scenario: Adding items to my basket
Given I have logged in as a customer
And I visit the "Clothing" page
When I add "Black Jeans" to my basket in size "M"
Then the total should be "£9.99"
Scenario: Removing items from the basket
Given I have logged in as a customer
And I visit the "Clothing" page
Given I have added an item of clothing to my basket
When I empty my basket
Then the total should be "£0.00"
Why would you need to access the Background description, if what you're actually testing is covered by the Scenario description?
That is why currently they do not offer this as a feature. It's additional information within a file that allow ease of reading and understanding of what is actually being tested - but if your steps are descriptive enough, do you need a description for the setup for a test?
This information is currently not available at runtime in SpecFlow. Please open an issue on GitHub for this, that we can potentially add this in later versions.
But generally it is bad practice to depend on such fragile (potential often changing magic strings).
Better way would be to check for a tag on Scenario or Feature level.
Also be aware, that you don't know at runtime, that you are currently executing parts of the background. There is no difference between these Given steps and the Given steps of your scenario.
I am using the "taxonomy display" module. I use to so that I can sort my taxonomy terms by title, instead of by ID, as it does by default. However, I also created a taxonomy template called:
taxonomy-term--product_literature_category.tpl.php
If I enable the "taxonomy display" module and override the taxonomy view for this path:
/taxonomy/term/%
... it also overrides the template I specified above. It would make more sense that the order would be to take my custom template override the module. But it doesn't seem to work that way. But if I disable "taxonomy display", it again takes my template into account.
I have two choices:
Enable "taxonomy display" and find a way to override taxonomy-term--product_literature_category.tpl.php
Disable "taxonomy display" and find a way to sort taxonomy terms by my own custom sorting parameters.
I would imagine 1 being difficult (because it doesn't make much sense to use two templates for the same thing). That is why I'm leaning towards an easier way to sort taxonomy views by default, or some other way to specify the ordering of taxonomy terms.
Does anyone know how to do this?
UPDATE
Right now I am going to settle with figuring out a hook to change the sorting of taxonomy terms via a module. That way I can override the sorting for only specific vocabularies. Any pointers to nudge me in that direction would be highly appreciated?
UPDATE 2
I've created teaser_sorter.module and added this function:
function teaser_sorter_views_query_alter(&$view, &$query)
{
print '<pre>'; print_r($view); print_r($query); die();
}
I also made sure my module supports views:
function teaser_sorter_views_api() {
return array(
'api' => 3,
);
}
I can't get it to ever reach my "die". In other words, it's never called. In fact, I also tried overriding "hook_views_pre_execute", but that doesn't ever get called either.
Any ideas?
view : <google-taxonomy-category class="googlecategoryselectiontool" field-name="goo_cat_id" cat-sel=""></google-taxonomy-category>
"class" used for template setup so if I want to use any.tpl then I simply have to write tplname. if no class value given then it will take default template.
"field-name" it will consist name of the request variable which you want to set on checkbox. by default its value going to be "selected_value[]" if no value passed for it.
"cat-sel" it will consist of data of which category need to be selected when html load. it will take value like <?php echo htmlspecialchars(json_encode($selected_value)); ?> in
which $selected_value is the array of all category id which need to be selected.
I use taxonomy terms to address my menus(these taxonomy terms show the structure of my site) so when I create a view I should use the taxonomy path (instead of alias) for the page setting (the only way that I can link the view to my taxonomy address path as far as I know :P ). whenever I see the page URL I can see the alias. now I'm trying to set up a page that has 2 tabs. I have set it up but the problem is when I click in the tab I see the taxonomy path instead of alias ? (for example taxonomy/term/6/digital instead of CCTV/digital However default menu tab still work correctly and show the alias CCTV)
Is there any way to show the alias instead of taxonomy term address ?
I assume that you have a view that is filtering your taxonomy terms. If you render the results as fields, each field can have it's formatter. If you need a custom form of the output, you can define your own formatter or generate one via GUI with help of: custom formatters.
In case that you render your output as rendered entity, you need to find the right template file and use the drupal_get_path_alias() function within it.
As last I would hint you a great module that also might help you: taxonomy menu
I have a taxonomy vocabulary "Department". In the user account I have a taxonomy term reference field with this vocabulary. So each user can be assigned to one or more departments.
I used the module Taxonomy Meny to show the taxonomy terms in my main menu.
Now I want to show a list of users when I click on a department in the menu.
Does anybody have an idea how I could do this?
Thanks.
Note sure here, but I suppose you should be able to use the views module to achieve this. Use can show all user nodes (or a list by choosing fields) and enter the department as a contextual filter.
Uou can use views in 2 ways, to produce pages or blocks. Contextual filters are a bit easier with pages, but that might confilt with yout module.
I like this tutorial, it gives a clear insight in contextual filters. It should get you started.
http://www.metaltoad.com/blog/using-drupal-contextual-filters-views
I have two lists of different PageTypes - NewsItems and PressReleases. They are displayed in one list each, with links to the individual items.
Now I want to include the press release items into the news list and use the style of the news items to display them as news items. They share properties like "Heading" and "BodyText", which are used in the News Template.
I imagine that it won't be that difficult to feed the NewsItems' ListPage with both sets of pages, but I don't understand how I can control the rendering of the item page.
I would like to take the PageData object from a NewsItem OR a PressReleaseItem and display it using the News-Item.aspx template, if it is selected in a NewsList. But EPiServer will always render the PressReleaseItem with the PR-Item.aspx since it's coupled in the PageType settings.
Anyone know how to accomplish this?
EDIT: An effort to clarify:
The important issue is how to know the "list parent" and choose the right template from that. In the ListPage I can apply different looks on the PR and News items respectively using tompipes answer, but when selecting to see an individual item EPi will render the PR-Item-1 the same way regardless of their "list parent". That's the problem.
I'm not following exactly what you are attempting here. But I think I get the gist of it.
Why not use one aspx template for both page types, but in the code behind switch off sections using the visible attribute.
If you are using PageTypeBuilder you could use the "is" keyword:
somePlaceHolder.Visible = CurrentPage is NewsItemList;
If you're not using PTB, you could use something like:
somePlaceholder.Visble = CurrentPage.PageTypeID == 10;
or
somePlaceholder.Visble = CurrentPage.PageTypeName == "NewsItemList";
I'll point out now I'm not a fan of hardcoding anything, so I would place the template name, or ID into a config file, or a property on the start/root page to avoid hardcoding them.
Let me know if this will help, or if I have misunderstood please try elaborate on your issue.
Depending on how much the templates share you could go with user controls, placeholders or even different masterpages to switch view in a suitable way.
To know when to switch you could use a querystring parameter, session variable or the nicest looking way would probably be to lookup and get the list's PageData object by the HTTP referrer. If it's empty you will get press release rendering as the worst case.
I tried lots of solutions, including the adding of querystring to the PR items in the list links, the getting of referring url in the item template and different types of event hooking for automatic publishing of news items from a PR item (although I only looked at the code samples for that one), and finally came to the conclusion that they all had something that told me not to go that way. (Making the code too complex, or the markup logic too hard to understand and so forth)
I ended up using Fetch data from another EPiServer page, and creating a "shortcut pagetype" in which I let my editors pick which PR item should be used as base for a news item.
This shortcut pagetype is called "PR-as-news-itemPage" and it is rendered with the same aspx as ordinary news items: News-Item.aspx. Having no properties of its own, it will take all relevant data from the PR item selected with "Fetch..."
To render PR items with all its properties I created an ordinary new pagetype called PR-Item.aspx. This renders the "Attribute 2" property, which is only rendered by PR-item.aspx, and not by News-Item.aspx.
(I could have gone even simpler, by letting the editors use the old News-Item page type and use the "Fetch..." property there, but I have some mandatory properties in that page type which I didn't want to make optional for this sake.)