I am at the final stages of a project but am stuck on that final step.
I have a partial view that forms part of a gallery, I want these gallery images to be filtered by a category (see below), I have this working in HTML
The category is specified via a drop down box when the item is added, however whilst the image appears when you select 'All' it does not appear when you select 'Slate' even though that is how it is tagged?
When you say you have it working in HTML what do you then mean by that? Is it a static HTML prototype? If so are you then making use of anchor/id and the :translate pseudo class in CSS? Or are you using a JavaScript like Isotope for instance? Or perhaps slick slider would be more appropiate in this case?
However I'm a bit puzzled about what the issue is? :) Is it that when you click the categories "Brass", "Plastics" etc. that the images you expect to see do not appear?
If you're not using some kind of JavaScript to achieve this then you would at least need to have a QueryString added, which Razor can look at and set the correct category based on what has been clicked.
Looking forward to hearing from you and sorry if I'm missing something from your explanation above but I think that a bit more detail about how it's working in your static HTML will help understanding how to guide you on how to make it work when implemented in the CMS :)
Sorry Jan I have reviewed my post and can offer more helpfull information and even corrections :)
Yes I do use some JavaScript to do this and it all works fine if I hard code the code to say 'Slate'
So for example, If i click on the 'Slate' button when it is hard coded the HTML for that Li would look like below and I would see the images that have been tagged with the word slate via the Category property.
<li class="span4 mix slate mix_all"">
However if I use the <li class="span4 mix @item.GetPropertyValue.Category"> Then I get nothing when I click on the word slate and the html looks like
<li class="span4 mix mix_all">
Note the double spaces between the two mix's in the code directly above, It is not outputting the value of Category.
This may not be an Umbraco problem but that was my first thought.
No need to be sorry :-) And thanks for the extra information.
Can you show what your static source looks like? I just need to see the whole context to fully understand how your code is supposed to be working since by looking at what is posted it seems to be "dark magic" - It might be that it's simply the "tag" value missing since it's not being rendered but looking at the code I'm wondering what the links/buttons for switching between the categories look like? Where do you get those values from? Are those also setup using the tags or are they hardcoded currently? If you have them rendered somewhere else using a foreach then I would like to see that code too since you should be able to re-use it I think.
If it works by the latest suggestion made by Paul then that's just fine of course but I would love to see and understand the full context - So if you could post the static working code example that would be nice :) - If you have a temporary link for the dev-site then that would be ace.
Adding @item.GetPropertyValue into a class
Hi All,
I am at the final stages of a project but am stuck on that final step.
I have a partial view that forms part of a gallery, I want these gallery images to be filtered by a category (see below), I have this working in HTML
The category is specified via a drop down box when the item is added, however whilst the image appears when you select 'All' it does not appear when you select 'Slate' even though that is how it is tagged?
The Partial view code is
When it renders on the page the HTML states
even though Slate is selected.
The options in the dropdown are exactly the same as the categories in the first picture.
Any Ideas what I am doing wrong here?
Thanks
Ben
Hi Ben
When you say you have it working in HTML what do you then mean by that? Is it a static HTML prototype? If so are you then making use of anchor/id and the :translate pseudo class in CSS? Or are you using a JavaScript like Isotope for instance? Or perhaps slick slider would be more appropiate in this case?
However I'm a bit puzzled about what the issue is? :) Is it that when you click the categories "Brass", "Plastics" etc. that the images you expect to see do not appear?
If you're not using some kind of JavaScript to achieve this then you would at least need to have a QueryString added, which Razor can look at and set the correct category based on what has been clicked.
Looking forward to hearing from you and sorry if I'm missing something from your explanation above but I think that a bit more detail about how it's working in your static HTML will help understanding how to guide you on how to make it work when implemented in the CMS :)
/Jan
Sorry Jan I have reviewed my post and can offer more helpfull information and even corrections :)
Yes I do use some JavaScript to do this and it all works fine if I hard code the code to say 'Slate'
So for example, If i click on the 'Slate' button when it is hard coded the HTML for that Li would look like below and I would see the images that have been tagged with the word slate via the Category property.
However if I use the
<li class="span4 mix @item.GetPropertyValue.Category">
Then I get nothing when I click on the word slate and the html looks likeNote the double spaces between the two mix's in the code directly above, It is not outputting the value of Category.
This may not be an Umbraco problem but that was my first thought.
Cheers
Ben
Hi Ben,
What if you do it like this would you then get the right value of the class
@item.GetPropertyValue(‘Category’)
Where Category are in single qoutes
Hope this helps,
/Dennis
Hi Ben
No need to be sorry :-) And thanks for the extra information.
Can you show what your static source looks like? I just need to see the whole context to fully understand how your code is supposed to be working since by looking at what is posted it seems to be "dark magic" - It might be that it's simply the "tag" value missing since it's not being rendered but looking at the code I'm wondering what the links/buttons for switching between the categories look like? Where do you get those values from? Are those also setup using the tags or are they hardcoded currently? If you have them rendered somewhere else using a foreach then I would like to see that code too since you should be able to re-use it I think.
If it works by the latest suggestion made by Paul then that's just fine of course but I would love to see and understand the full context - So if you could post the static working code example that would be nice :) - If you have a temporary link for the dev-site then that would be ace.
Looking forward to hearing from you.
/Jan
Hi Dennis
<li class="span4 mix @item.GetPropertyValue('category')">
doesnt work and neither does<li class="span4 mix @item.GetPropertyValue(category)">
I have tried capitalising the C as well but no luck i'm afraid.
I m missing something obvious im sure but you know what its like, I have been staring at it for ages and just cant crack it.
@item.Content.GetPropertyValue("category")
Or
@item.category
Try that :)
@item.category worked a treat, I'm sure I had tried that as it is the most obvious.
Looks like I was over complicating it. Cheers Paul
Hi Ben
Happy to hear that it works for you :)
Would still love to see your structure for the other pars mentioned - I'm just being curious that's all :)
Cheers, Jan
is working on a reply...