Erdem Gundogdu
Erdem Gundogdu

Reputation: 297

How to select only published items in XSLT-Umbraco?

i have a photo slider,there is next and prev buttons ,and when you click on a button,a pop-up window appears and show the big size of photos.Im using Umbraco,the xslt macro shows the nodes within the Gallery folder.xslt selects "Gallery/Photo" nodes.When i upload a photo,if i dont publish it,the sliders's next/prev buttons dont seem and pop-up dont work.How can i select only published items in Xslt ? Thanks in advance

Upvotes: 0

Views: 979

Answers (2)

Digbyswift
Digbyswift

Reputation: 10410

Without seeing your XSLT its difficult to guess what you're doing. However as @Goran states, XSLT in Umbraco can only access published nodes. This is because the data the XSLT has access to is the cached XML structure found in umbraco.config.

So, what is probably happening is that you actually want to exclude nodes that don't yet have an image assigned (even though the node itself is published).

You can do this using something like:

$currentPage//GalleryNode [image != '']

This will select all the GalleryNode elements under the current page that have an image property assigned.

If this is the case, you may want to consider making the image property mandatory to prevent any nodes from being published without an image.

Upvotes: 0

Goran Mottram
Goran Mottram

Reputation: 6304

I see this debate has sprung up again. It's not a direct answer to the problem, but should you understand Umbraco a little better ...

Umbraco & XSLT

Although Umbraco runs all it's data predominantly from a MS SQL database, it does however cache this data everytime a page is published/unpublished within a "hidden" XML file. It frees up the developer of any direct XML editing and leaves it to Umbraco. However, this makes it easy for a developer to forget or not even know it's there.

The file can be found in either of the following locations, dependant on which version you are using:

~/App_Data/umbraco.config
~/config/umbraco.config

The Problem

The XSLTs run using the umbraco.config file as it's XML source. However, this file will only contain published nodes. Unpublished nodes will be removed from the XML completely, so the XSLTs shouldn't be able to access unpublished nodes at all.

I suspect the problem may have to do with something other than unpublished nodes.

Upvotes: 1

Related Questions