What I am trying to figure out is to modify this query to list only the content with a certain tag, "teller". The doctype is "page" with some text and a tag selection. The following is working, it just lists everything. Can someone point me in the right direction?
Without seeing your tree and properties can't be too specific, but can give some ideas.
@{
var selection = CurrentPage.Site().FirstChild("ApplicationDatabase").Children.Where("Visible && "yourtagpropertyname" == "teller");
}
or
@foreach(var item in selection.Where("yourtagpropertyname" == "teller")
or use an if statement in the foreach, so if item.yourtagname == teller.
Can't help but notice your @: , you should not need them, and you should be able to remove the @ on the foreach. I think what is throwing your code is the , if you take that outside the container div it will make life a bit easier for you.
I don't why but it complains about not being able to use the && because one is a bool and the other is a string.
CS0019: Operator '&&' cannot be applied to operands of type 'string' and 'bool'
Another strange thing I have notice is that my code only works when i put the @: in front of the divs. I dont understand what you meant about that in the last post about making my life easier.
Here is a screenshot of my tree and properties. Thanks for helping I am still very new to this.
Will give you some code and try to explain it as we move.
@{ var topNode = CurrentPage.AncestorOrSelf() }
OK, this var will take you from the page you are on, to the top of the content tree . As I cannot see that tree, if your top node is at position 0, this will work, if your top node is the one below that, put a 1 inside the brackets.
@{foreach var item in topNode.Descendants("ApplicationName").Where("yourPropertName" == "teller"){ ..........}
This foreach will go down the content tree until it finds a document type called ApplicationName. I cannot see on what document type your property that can have the value of "teller" is, so you will need to substitute as required. The Where statement should contain the name of the property on the doctype that equals "teller".
In theory that should work.
The @: this is to break the code? But does make your code really confusing with @ and @:
If you use @{ before the foreach, as above, the code block should remain open, but I have just noticed that your row text-center div starts outside the block and finishes inside it, that is what is confusing the razor. Moving the outside the } will mean you can remove the @:s. My comment was not to offend but help by cleaning it up a bit, making it easier to see the blocks.
Hope this helps, happy yo help further if you need.
AHH!! thank you thank you. I didnt realize my div was inside the block. I fixed that and now I dont have to use the @: anymore.
I am still having trouble with this query. I am going to attach the pictures you need. I have applied this and when it runs i dont get an error but nothing loads, just the rest of the page template.
Query to list results by a certain tag
What I am trying to figure out is to modify this query to list only the content with a certain tag, "teller". The doctype is "page" with some text and a tag selection. The following is working, it just lists everything. Can someone point me in the right direction?
Hi Dustin
Without seeing your tree and properties can't be too specific, but can give some ideas.
}
or
or use an if statement in the foreach, so if item.yourtagname == teller.
Can't help but notice your @: , you should not need them, and you should be able to remove the @ on the foreach. I think what is throwing your code is the , if you take that outside the container div it will make life a bit easier for you.
Hope it helps
Gary
I don't why but it complains about not being able to use the && because one is a bool and the other is a string.
Another strange thing I have notice is that my code only works when i put the @: in front of the divs. I dont understand what you meant about that in the last post about making my life easier.
Here is a screenshot of my tree and properties. Thanks for helping I am still very new to this.
Hi Dustin
Will give you some code and try to explain it as we move.
OK, this var will take you from the page you are on, to the top of the content tree . As I cannot see that tree, if your top node is at position 0, this will work, if your top node is the one below that, put a 1 inside the brackets.
This foreach will go down the content tree until it finds a document type called ApplicationName. I cannot see on what document type your property that can have the value of "teller" is, so you will need to substitute as required. The Where statement should contain the name of the property on the doctype that equals "teller".
In theory that should work.
The @: this is to break the code? But does make your code really confusing with @ and @:
If you use @{ before the foreach, as above, the code block should remain open, but I have just noticed that your row text-center div starts outside the block and finishes inside it, that is what is confusing the razor. Moving the outside the } will mean you can remove the @:s. My comment was not to offend but help by cleaning it up a bit, making it easier to see the blocks.
Hope this helps, happy yo help further if you need.
Regards
Gary
I just realized something, in this code:
teller is the tag I am trying to find by. I noticed you said "should contain the name of the property on the doctype that equals "teller"."
AHH!! thank you thank you. I didnt realize my div was inside the block. I fixed that and now I dont have to use the @: anymore.
I am still having trouble with this query. I am going to attach the pictures you need. I have applied this and when it runs i dont get an error but nothing loads, just the rest of the page template.
Hi Dustin
We are getting somewhere.
Rather than ask loads of stuff, if you remove the Where statement, see what returns,
If nothing, put the 1 inside the AncestorsOrSelf(1), like that.
If something returns, then applicationUsers, maybe ApplicationUsers.
It's now something simple, so should get result soon.
Cheers
gary
Thanks for your help!!
is working on a reply...