For this reason i created a new mediaType called "banner" which has some properties (file, width, height) and one property called "bannerShowOnPage" which is a MultiTree Node Picker.
This Multi Tree Node picker selects some Content IDs where the banner should appear.
How must the XSLT look like if i want to check if for the currentPage there is a banner? I cant get it work
If I understand, your bannerShowOnPage MNTP field is actually on the Media Type and not the actual page/document, correct?
If so that will be a bit more tricky, I think you'll have to loop through each media item in a given folder and look for the currentPage's ID in the bannerShowOnPage field. Is that your situation?
I add an image an choose via MNTP the content where it should appear. So a banner can be shown on selected pages without beeing added to each content from the content section.
<xsl:variable name="mediaFolderId" select="1127"/> <!-- replace 1127 with the ID of your folder that contains the banners -->
<xsl:for-each select="umbraco.library:GetMedia($mediaFolderId, true())/banner"> <!-- replace "banner" with your media type alias --> <xsl:variable name="mediaNode" select="."/> <xsl:for-each select="./bannerShowOnPage/MultiNodePicker/nodeId"> <xsl:if test=". = $currentPage/@id"> <img src="{$mediaNode/umbracoFile}" alt="[image]" height="{$mediaNode/umbracoHeight}" width="{$mediaNode/umbracoWidth}" /> </xsl:if> </xsl:for-each> </xsl:for-each>
This could probably be optimized a bit. I was trying to avoid the second for-each loop with something like <xsl:if test="count(./bannerShowOnPage/MultiNodePicker/* [nodeId = $currentPage/@id]) > 0"> but couldn't get that working.
I just tried to use a URL and it works - i create a property (textstring) for an external url (bannerExternalLink)
Now i want also to create a content picker for internal links (property "bannerInternalLink"). If the bannerInternalLink is != "" it should use this otherwise he should use the bannerExternalLink
Also, I might suggest using the URL Picker datatype from uComponents to simplify selecting the link for your content editors, it's one datatype that allows the editor to select internal/external/media/upload (you can control what options they can select), add a caption and check whether it should open in a new window.
I added a new property called "position". This can have values like "footer, skyscraper, header" for example.
Now i want to check if there is one of the position "footer" and only show the banner with this position. i think i must put an if statement arround all of my xslt code? is this correct.
I just tryed to use the sort function of umbraco to put some banners to the top of the list (if there is more then one banner for the position). But this was not working.
Use Multi Tree Node picker for images
Hello everybody.
I want to develop a banner management tool.
For this reason i created a new mediaType called "banner" which has some properties (file, width, height) and one property called "bannerShowOnPage" which is a MultiTree Node Picker.
This Multi Tree Node picker selects some Content IDs where the banner should appear.
How must the XSLT look like if i want to check if for the currentPage there is a banner? I cant get it work
This is my XSLT right now (which does not work):
Hi Dominik,
Try replacing the "GetXmlNodeById" line, with...
Cheers, Lee.
thanks but the problem is that the xslt does not go inside the if statement.
so the first line:
does not work.
How can i get the image for the content i selected in the Multi Tree Note Picker.
I think this is the problem
If I understand, your bannerShowOnPage MNTP field is actually on the Media Type and not the actual page/document, correct?
If so that will be a bit more tricky, I think you'll have to loop through each media item in a given folder and look for the currentPage's ID in the bannerShowOnPage field. Is that your situation?
yes you are right i need this property on the image and not on the document.
So I need some help how to setup this. I think it would be great if I get this working.
I want just to check for each currentPage if there is an image for this ID (from the selected MNTP values).
Is there a way to handle this?
just to explain what i want to realise:
I add an image an choose via MNTP the content where it should appear. So a banner can be shown on selected pages without beeing added to each content from the content section.
Hi,
Here's a down-and-dirty way to do it:
This could probably be optimized a bit. I was trying to avoid the second for-each loop with something like <xsl:if test="count(./bannerShowOnPage/MultiNodePicker/* [nodeId = $currentPage/@id]) > 0"> but couldn't get that working.
Hope this helps,
Tom
Thanks
But if i choose a folder with the MNTP the banner is not shown in all of the child pages. How can i get this also working?
For example if i choose the root node the banner is shown on all sub nodes
So if you choose About Us, you want the banner to show on all subpages of About Us also?
Try changing
to
-Tom
ok it works,
thanks for your help.
Now i have got the next question :-)
I just tried to use a URL and it works - i create a property (textstring) for an external url (bannerExternalLink)
Now i want also to create a content picker for internal links (property "bannerInternalLink"). If the bannerInternalLink is != "" it should use this otherwise he should use the bannerExternalLink
THis is how my externalLink is working until now:
Hi,
You can determine the href attribute with a choose statement, like so:
Also, I might suggest using the URL Picker datatype from uComponents to simplify selecting the link for your content editors, it's one datatype that allows the editor to select internal/external/media/upload (you can control what options they can select), add a caption and check whether it should open in a new window.
-Tom
Thanks - it works great
I think i will come back to you if there are some more question.
Hope this is ok? :-)
Ok now i have got another question:
I added a new property called "position". This can have values like "footer, skyscraper, header" for example.
Now i want to check if there is one of the position "footer" and only show the banner with this position. i think i must put an if statement arround all of my xslt code? is this correct.
Perhaps you can help once again :-)
Hi dominik,
You can add this condition in your original for-each loop, ex:
-Tom
Thanks
I now try to integrate a show from until field.
I got it working via this xslt:
What is the best method to only use this statement if there is filled out a date. If there is no date selected it should be shown all of the time.
ok I think i get it working by simply putting some "or" functionality inside the if statement.
I just tryed to use the sort function of umbraco to put some banners to the top of the list (if there is more then one banner for the position). But this was not working.
Here is my xslt
Is there a possibility of using the umbraco backend sort functionallity to display the banners?
Hi i just updated to version 4.7 but the sort function for media item still not work.
I want to display the media item with the lowest sort order id at the top.
Anyone any solution for this problem?
is working on a reply...