I have 2 content types "lab" and "member". When I display "lab" data, I want to display "member" from this lab.
I defined a contextual filter in a display "entity reference list" of a view, which run in preview.
I defined a reference field in "lab", which "reference method" is the above "entity reference list". But about the views arguments which have to passed to the views?
Regards,
E. Cocquebert
I succedded to have what I wanted.
It was not a "entity reference" display but a "block" display.
"entity reference" is to help to fill the form display
"block" is to display result of the contextual filter when display a specific node (in my case).
Regards,
E. Cocquebert
Related
I'm trying to make a poll results page with the results from a WFFM form. I initially took all the entered data(using AnalyticsFormsDataProvider), queried it, and then displayed the results. However, if no one votes for a particular answer, it wouldn't be in the entered data so it wouldn't show.
I want to display that the field had 0 votes, so now I'm trying to compare the possible answers to the queried list. However, I can't seem to find a way to access the values of the list items. Does anyone know the class those values are stored in and/or how to access them?
I'm using WFFM 8.1 rev. 151217 (Update-1) with MVC. It's a radio list field if that makes a difference from the other list fields.
Thanks,
You are able to get WFFM field as regular Sitecore item via standard API.
Available list items values are saved in "Parameters" and "Localized Parameters" fields. You can use Sitecore.Form.Core.Utility.ParametersUtil from Sitecore.Forms.Core to parse values saved in these fields.
This data is stored on your Radio List Field's Item in the fields Parameters and Localized Parameters.
If your code is within the Form's SaveAction or a Validator you will have access to the Field in the for AdaptedResultList args the SaveAction or via this.classAttributes["fieldid"] for the Validator. That will be enough for you to get the Radio List Item and then the Parameter fields.
If your code is not in a SaveAction / Validator I recommend passing the Form Item into your code possibly by Datasource and then retrieving the Radio List Item from that.
Finally the Items of the your Radio List field is stored in the format
<item><item>
If your radio items are actually items you will want to parse them using a regex
var regexItems = new Regex(#"<item>(.*?)</item>".ToLower());
var itemNodes = regexItems.Matches(FieldItem["Parameters"].ToLower());
Then you should be free to play with the list for your poll
In my template I have a field type of Droplist which maps to a Sitecore folder holding values for the Droplist which in this case is Colours. This is so that an editor cannot make a typo or invent a colour this is not in the pre-defined list.
So that colour is based off a template I call TAGS which has a single field type of 'colour' and here I create a series of items using that template to create the colours for the swatch list.
When I access the main template I duly see the colour values in that Droplist so its working as I would expect it because I can access that fields values:
tileValues.Attributes["class"] += " tile-" + Item.Fields["Tile Colour"].Value.ToLower();
However I have realized its not using the field value of the template but rather the name I have called the item. SO its just a happy mistake that its achieving the result I wanted.
However how would I obtain the actual field value for that item in the end code. I have scenarios where there will be multi lingual editors so we may name the tags as rouge, blanc etc which is what the editor will see on selection in the Droplist but we need the colour value of the field to still say red or white etc
I tried:
Item.Fields["Tile Colour"].Item.Fields["Colour"].Value
But this failed despite the API hint implying its valid.
I hope this makes sense and someone can help me obtain the actual field value and not the items name.
As Sitecore Climber wrote, don't use Droplist field type - it stores item name only and you cannot get the item itself in the code behind.
Use Droplink field type - it stores ID of the item.
Then you can get the item:
Item colourItem = Sitecore.Context.Database.GetItem(Item["Tile Colour"]);
if (colourItem != null)
{
string colour = colourItem["Colour"];
|
I am creating an app in django and to do that I have a form where the field 'Person' is a ForeignKey field. So, when I run the application it appears a form correctly showing me a combobox that lets me select the 'Person' object that I want. But the problem is when I try to catch the information in the view.
I send data with a POST method, so, when I try to get the value of the selected 'Person' object in the view I do the next:
selected_person = request.POST['person']
(Person is the field name)
I was surprised when I tested that the value of the variable 'selected_person' is a number (concretely, the number of the selected index of the element in the combobox).
My question is: HOW CAN I GET THE OBJECT VALUE OF THE SELECTED ELEMENT IN THE COMBOBOX?
Than you so much!
No, it is the primary key of the Person object in the database. So you can get it via Person.objects.get(pk=selected_person).
But really you should be using a Django form, which will then give you the Person object via form.cleaned_data['person'].
Also note, for clarity, this is a select field, or a drop-down, not a combobox; a combobox is a desktop widget that has both a drop-down and an edit field.
Concretely, the problem was I didn't have defined a "primary_key" value in the model, so, the number that the drop-down list gives me is the default primary key that django attached to the model. If I define a customized primary key for the model, the selection of the element in the drop-down list gives me the primary key.
With Opencart 2.0.1.0, I created categories. When i try to assign them parents, no category shows up.
Screenshots attached:
http://snag.gy/30giO.jpg
http://snag.gy/WmaCx.jpg
http://snag.gy/nyFrF.jpg
the autocomplete of choosing category only show the first five matches by default. Maybe you can type more character to get those categories?
Ref to: \admin\controller\catalog\category.php function: autocomplete()
I have a sitecore item, "category", which has a drop link which populate "product type" template list.
Each category can have a "product type".
(Products being created under a category node will be using the template selected in the drop down. e.g. Shoes category will have a Shoes template, Slippers category will also have a shoes template, Bags category will have a bags template).
Problem:
These categories should be able to mark related categories. Therefore I need to show a treelist kind of a control which only allows options to select categories with same "product type".
Under "Shoes" category, I need to have "Slippers".
How can I do this?
After selecting "Slippers" as the related item to "Shoes", if the user tries to change the "product type" drop link value in "slippers", how can I warn the user that this product type has already linked to another category?
(Validation on saving the category item.)
Hope this is a common issue with Related items in Sitecore, yet I could not find a solution for this.
Your first problem, "marking related categories" is not clear to me what you want to achieve with it.
But if I understand you correctly, you want to select a product-type-template in the Category-item to let the editor create products of the chosen producttype below the Category-item.
You can resolve this by using the item:saved event on the Category-item:
- first check if you are saving an item of type Category but checking the template.
- If it is a Category-Item, read the value of the product-type droplink and on the fly add this template to the insert-option of the Category item.
Your second problem with the check on related items can merely handled the same way by using the item:saving event. Not the item:saved event because you want to do the check before the item is saved so you can cancel the saving and display a messagebox through the Sitecore.Web.UI.Sheer.SheerResponse.Alert() method.
In the item:saving event you need to check if the current item has 1 or more referrers (items that link to this item) through the LinkDatabase method Globals.LinkDatabase.GetReferrers().
Using validation on this instead of the item:saving event is not usefull because the validation event only throws a warning and saves the item anyway.
Another good link with example code is this blog of John West.