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
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.
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.
Related
We are currently use the oob page types for Blog, News and Event. We have one page for each of these types that includes a repeater to show a list of the pages of that type. We would also like to have a page that includes a repeater that shows all blog, news and event pages in one spot, sorted by their created date.
I have seen some old comments (here, here) on devnet saying that although a repeater can render multiple page types, the fields rendered must be identical across each of those page types. The workarounds suggested are either to create the same fields in each page type, or to create a custom SQL query and use a query repeater to render the data. I've done this and it works just fine, but it was pretty cumbersome to create and will be difficult to maintain. (If we want to add other page types, for example.) Can anyone suggest a more out-of-the-box method available in Kentico 10?
Update:
I'm trying to accomplish this as Brenden described, but am running into trouble.
My page structure is as follows:
Root
.RollupPage (CMS.MenuItem)
..BlogPosts (CMS.Blog)
...January 2017 (CMS.BlogMonth)
....blog post 1 (CMS.BlogPost)
...February 2017 (CMS.BlogMonth)
....blog post 2 (CMS.BlogPost)
..Events (CMS.MenuItem)
...Event1 (CMS.BookingEvent)
...Event2 (CMS.BookingEvent)
I've attempted to use a universal viewer, but failed to get it to return any data.
I configured it with:
Path: /RollupPage/%
Page types: CMS.BlogPost;CMS.BookingEvent
Hierarchical Transformation: CMS.MenuItem.HierTrans1
HierTrans1 has the following transformations:
CMS.BlogPost.Default (Item transformation for type CMS.BlogPost)
CMS.BookingEvent.EventCalendarItem (Item transformation for type CMS.BookingEvent)
These aren't customized at all; they are standard OOB transformations just so I can see it work.
When I view the RollupPage, the universal viewer displays nothing.
I attempted to use a Hierarchical Viewer with the same settings as I did with the Universal Viewer. It kind-of worked. It displayed my booking events but did not display any blog posts. Yet using the same blog post transformation (CMS.BlogPost.default) with hierarchical viewer whose Path was set to /RollupPage/BlogPosts/% displayed my blog posts correctly but, obviously, did not display my booking events.
The results I've gotten so far makes me think a) something about the way I've created my pages is stopping the universal viewer from traversing the whole tree and/or b) the hierarchical viewer either only goes a couple of levels deep, or maybe it is being blocked from traversing the tree too... No events are recorded when I edit or view these web parts.
Any idea what I may be doing wrong?
For this scenario use a universal viewer. Reason being is you can create a hierarchical transformation which will have different transformations for each of your unique page types. You most likely won't use the hierarchy at all but you can simply add 3 different item transformations for the different page types.
You can use the Hierarchical viewer or the Universal viewer, as Brenden Kehren mentioned, to achieve the goal you are describing.
When configuring the web part you must select all the Page types that are included in the hierarchy, in your case: CMS.MenuItem, CMS.Blog, CMS.BlogMonth, CMS.BlogPost and CMSBookingEvent.
Create a Hierarchical transformation to be used with your viewer and add an Item transformation for each of the items you wish to display. Also make sure the Level setting for each transformation is configured properly (-1 applies the transformation to all levels).
For Universal viewer it is necessary to check the property Load hierarchical data in the section Extended settings of the configuration.
As an additional note, you can leave the path property empty in case you are viewing the child documents of the current page.
For reference there is also an example on the Corporate Site example site in the content tree path Examples > Web Parts > Listings and viewers > Pages > Hierarchical viewer (or Universal viewer).
Hope this helps!
The other ways are this
Evaluate right fieldname by check object classname inside the transformation and assign appropriate value.
Dynamically assign transformation by checking the object classname
I used to implement listing/detail scenarios using wildcard items, meaning that, for the sake of URL, I create a regular item to display the list and then under that node, I create a wildcard item to represent all possible detail pages, like:
/news/*
(i generate a friendly name by code to replace wildcard and produce the full URL such as: mywebsite.com/news/the-meeting-press-release)
Then I create a folder or a bucket of content items somewhere else as my repository. Then I assign same datasource to listing node and wildcard node to give them same repository of content items.
Main reason I want to do this is to use datasources and make navigational nodes (which generate actual pages and URLs) to be separate from Content folder structure. In other words, separation of concerns: navigational items as presentation nodes and content items as my data repository.
This is an easy way to work around master/detail requirements but I always feel guilty about this, it feels like this technique breaks integrity (sitecore links table on database) and design pattern in Sitecore back-end.
For example when I look at Analytics, I get * as name of items, clearly the it feels like aliens to back-end system.
I know this is not a new topic. I have seen threads like this or ideas like Sitecore Pipeline Processor for Virtual Items to implement such requirements.
Is there any best practice about this? Have anyone good example of what is most sitecore-friendly way to implement such pipeline processor? How do you address this issue with wildcards on Analytics?
I'm going to go a different way to Martin here. I have successfully used Wildcards many times for the exact purpose you are suggesting (For an example have a look at http://www.atpworldtour.com/news - all news articles are items in a bucket with a wildcard to resolve the url).
There are 2 options to enabling the page editor.
The news article item becomes the page. In this way, you need a new processor in the httpRequestBegin pipeline that resolves the url to the item and then sets Sitecore.Context.Item to the current item. IIRC you do this by setting one of the pipeline argument properties. This will work fine in the page editor as the context item - the one being edited - is the news article. And then other renderings on the page can just use data sources as needed.
The news article resolves to a Datasource. I have also tried this method. To do this, you need a custom Datasource resolver. I sill used a processor in the httpRequestBegin pipeline so that I didn't have to resolve the Url multiple times for each rendering that needed the datasource. But then in the RenderRendering pipeline I had a processor that detected if I wanted a wildcard Datasource and used the item that had been resolved in the httpRequestBegin processor.
There are pros & cons for each method.
Option 1 is nice and simple. It means that you could use a single wildcard to resolve different "types" of page item as the presentation is on the page item and not the wildcard item, also each item can have its own custom presentation, so Datasources set in the page editor would be unique to an article. That is also a disadvantage in someways. A/B testing becomes more difficult with main article text etc... You are limited to testing article versions.
Option 2 is more flexible in the testing area - you can easily test/personalize parts of the article by changing the Datasource. But you are more limited as the presentation must be set on the wildcard. So renderings that are not part of the main article will have the same content/settings across all news articles.
I was previously in the same boat as you are. The are few issues with wildcard items, like resolving datasources or disability to run a page in Page(Experience) Editor or nested wildcards. Regardless of that, I have used wildcard few times and they do their job.
I've managed to resolve datasources properly, based on URL (see blog post: Automatically resolving correct Datasources for wildcard items based on URL), still did not sort the rest others.
Update: Richard suggests the way of implementing Page Editor below, you may find this helpful
Thus, my answer would be:
I would recommend you to keep classical approach of having a page item for each news item, rather than using wildcards. Content authors would use habitual approach (and page editor) rather that editing datasources somewhere on the content tree in Content Editor. If you configure that properly with templates and standard values - there would minimal hassle to create new news article.
In case if you worry about potential raise of number of news articles - use Buckets along with it (or suggest manual strategy to group them into folders).
After a deploy to our Acceptance environment, templates in sitecore seem to be broken. We have installed them back with an item package from a working environment and did a revert on the /sitecore/templates/system tree.
We didn't notice any difficulties here, but when we try to edit with a rich text editor, we see the raw values. Even a tree list is rendered as a single line text field.
Next to that, the /sitecore/templates/system/templates/template item does not contain any fields.
Since we are on an acceptance environment, we cannot revert the entire database in case of data loss.
Do not think I entirely understand your issue, can you please be more specific and give us more details? You say templates are broken, but in what way exactly?Can you try reproducing that to ensure it happens again?
If you see everything as a text value, that happens because of you have Raw values in View tab switch on.
Question: Can anybody let me know on how to clear a sitecore xslt cache?
Problem : We have implemented Main Navigation and Footer Navigation from the same items in Sitecore.We had a urgent requirement to remove an item from Main Navigation and Footer.
We removed the item from Main Navigation by unpublishing the item in sitecore.However footer is implemented using XSLT as below :
<sc:xslfile visible="true" runat="server" id="xslFooter" cacheable="true" varybydata="true" />
Now even though the item is unpublished,it is still visible in the footer of the site and my guess is, it is because of XSLT cache.So can you please tell me on how this can be done.
Note:I can't write any code for this now as I need to remove immediately from live site.Also I can't clear using admin tool as it clears cache for all users?
So any solution for this?
Thanks,
Suhas
If you go to /sitecore/admin/cache.aspx you will be able to clear the cache, but I assume this is the admin tool you don't want to use.
You say that you don't want to clear the cache for all users, but I can't see a way around this because the cache is not user/visitor specific.
If acceptable, you can also clear the XSL cache by renaming/updaing/adding a file in the XSL folder.
The issue has been discussed here:
Sitecore XSL cache
I'v done a tree view in xsl using a javascript function
I want to change the icons depending on the status (+ for to open , - for to close)
This questions is as clear as thick molasses in a pool of mud. (Will try to answer, though.)
I assume you mean XML stylesheets with xsl. If you meant Excel, it should have been xls. But let's assume you mean stylesheets and you're using it to generate a webpage which contains a treeview. In this treeview there are icons indicating if the node is expanded or not. If expanded, display +, else display -. Am I right, here?
Now, it depends on how you've implemented this treeview in your stylesheet. The most practical way would be to just send the tree data fully expanded to the page and let the Javascript handle this client-side. In that case, all you need to know is how to expand and collapse nodes in Javascript with the additional icon change.
Another possible implementation would be when expanding and collapsing is done serverside, thus you'd only send the visible data. In that case you can also just tell the page which icon to use and there would be no need for any javascript. The icon would just be a link back to the server, updating the data through a new requests which builds a new webpage.
A third option would be the WEB 2.0 solution, where you just send the list as a collapsed treeview and every time the user clicks an icon, a AJAX event gets triggered, collecing the additional node data and changing the icon of the treenode.
These are three very different techniques and they're not always the best solution. The first solution is a problem when dealing with lots of data in your tree. It needs to load it all. The second option will generate a lot more traffic with the server but handles better with large amounts of data because you only display the open node. The third option is a bit of a mixture between the first two options. You don't need all data from the beginning and you're not recreating the webpage over and over again. But it's also more complex to code.
Now, I wonder which of these options you use. Once we know this, we can help you. (Edit your question to provide this information and perhaps even add the JavaScript tag to it.)
To be honest, xsl is only used to change the shape of an XML document and it knows nothing about treeviews or whatever. So I don't see any link between xsl and treeviews. It's just that you use xsl to transform your data into something that some Javascript library can process as a treeview. Which Javascript library is this?