In Sitecore, how can I get a list of all pages on which an item appears? Thanks
Internally Sitecore maintains a database of references between Items called the Link Database. You can query this by using the "Links" dropdown on the "Navigate" tab on the Content Editor ribbon. That may give you the information you need.
(You can also query the Links Database via code - See example code on http://laubplusco.net/sitecore-item-extensions-get-referrers-as-items/ for one example of doing this - or the docs in SDN)
If the relations to your target Item are via selection field types (multilist, treeview etc) or via the DataSource property of Renderings/Sublayouts/etc then you should be able to select the item you're interested in and click the "Links" dropdown to see a list of the relationships Sitecore has recorded. This will list system relationships (which template does this item use) as well as the sort of relationships you're interested in where one item points at another item.
Note that this approach cannot tell you about some types of relationship: the most common sort being ones which are calculated at runtime. (EG API queries, or searches) because those relationships don't exist in the Links Database.
-- edited to add --
You ask about getting the URLs for these Items. In code you can get the URL for an item by calling LinkManager.GetItemUrl() and passing in the item you're interested in. That gives you the public website URL, rather than the Sitecore Item Path that you'd get directly from the Link Database.
Related
I'm building a products table to show all the products attributes. However I need to allow users to add/edit/remove those attributes from the products later on in production without any dev work. I thought about branch templates but when I edit the branch template, existing products are not getting updated. Maybe I'm looking in the wrong direction? Any suggestions?
In an older project we have a similar setup with product and attributes and used a custom database to help us out:
products are stored as items in Sitecore
attributes are stored as items in Sitecore
a custom database stores the values of all attributes for all products
publish events are used to keep the custom database in sync when deleting products
on a product template we added an extra tab in the content editor including an aspx page that offers an editor on our custom database for that product. We use the products Sitecore ID and display all possible attributes in an editable way.
Most attributes have simple string values but that is extendable. Our attributes have a type (string, bool, (multi-)list, ..) and we use that to create the editor. The lists refer back to Sitecore items (a parent is selected on the attribute item).
Adding an extra tab in the editor can be done by creating a new item in the core database (/sitecore/content/Applications/Content Editor/Editors) that point towards your aspx file. In the standard values of your product template, you select the created "editor" in the Appearance section. (note that this is in Sitecore 6 - might have been changed although the path to the editors is still valid)
This solution does mean that the values of your attributes are stored outside Sitecore, but it worked for our requirements.
I'm wondering whether anyone has come across the following issue. We're currently working on a Sitecore website that uses integrated uCommerce to provide eCommerce functionalty.
Rather than passing category and product ids to a static url that maps directly to an item in the sitecore content tree e.g.
domain.com/category/?category=123
domain.com/category/product/?product=321
We want to be able to have URL's like follows:
domain.com/category-name/product-name
Generating this url shouldn't be too difficult if we use IUrlService provided by uCommerce.
Is there an easy solution to get these sort of URL's to map to a particular item in the Sitecore content tree and ensure the uCommerce context is updated accordingly?
Thanks in advance for any help received.
I am using the Sitecore Commerce Connect framework and am using wildcard URLs for my products and categories. Since my products often appear in several categories, I have kept the structure of having separate URLs for products and categories to make sure that the URL for the product is not repeated if it appears under several categories.
Home/product/* is my the wildcard item for products
Home/category/* is the wildcard item for my categories
The wildcard manager will then allow me to render the product and category pages based on those pages where I just resolve the item in Commerce connect by the information provided in the URL.
The custom LinkManager will then provide the references to the correct URL when fetching a link for and item and it will not risk having the URL changed if I do changes to the category structure or add it in several categories.
We have developed a Sitecore site for a client who will primarily be using Page Editor. We've built page type layouts and then componentized everything else, including sub-layouts of content. This allows them the most flexibility when building pages.
So, an author goes to a page selects the main content area (Placeholder) of the page and inserts basic building block components that we've created. These include Rich Text box, page promos, etc. they can use these to build pretty rich pages with lengthy content.
All page components have the same Datasource Location, which is a "Page Components" folder that's setup as an item bucket.
This is all working well so far.
Now, I'm trying to make it so when a page is created a specific component is created, inserted into to our "Page Components" bucket and placed in a specific placeholder on the page.
I've been trying to build a Branch Template to accomplish this, but I don't see how to specify that the new component should be stored in our bucket location, instead of directly underneath the Page item. Also, how to make the component show up in the placeholder that I want on the page.
Is this possible? Thanks in advance for you help!
You will want to use a command template for this, since you are desiring to programmatically bypass Sitecore's standard layout configurations and branch template creation.
On your page template standard values, you will want to add the sublayout to the presentation details so you can hook the datasource in programmatically after creation.
The fundamental flow in the command will be as follows:
Create the desired page item
Create the desired component datasource in the bucket location
Search the layout definition of the created page item to find the appropriate sublayout to bind to.
Alter the datasource on the sublayout to bind to the datasource you created.
As #jammykam mentioned, there is a recent blog post now available.
I have a question about the Drop List field type of Sitecore Web Forms for marketers.
I want to build a web page which has two drop lists that are connected. When the first one changes, the other one's data changes based on the selected value of the first one.
How do I achieve this?
This is not possible out of the box. You will need to build a custom WFFM field that will store the 2 droplist. If you need more information on how to build custom WFFM fields you can checkout this blog post.
I am new to Sitecore and have come across a situation for which I haven't been able to find any documentation.
I have two blogs, Blog A and Blog B. Each Blog has various Categories.
Now, I am trying to create a template, where the user can select a Blog and then select Categories. For Bog Selection, I have used a Droptree and for Categories Selection, I have used a Multilist. I can fetch all the Categories using the following query :
query:../../..//*[##templatename= 'Category']
But, this fetches all the categories belonging to both the Blogs. What I want to do is - when the user has selected the Blog in the DropTree, I want to populate the Multilist only with the categories belonging to that particular blog.
Any ideas? Thanks!
I don't think Sitecore Query supports what you're after (basically using a field value from another item as a variable in a query, if I understand correctly).
There's a guide to the whole of query on SDN: http://sdn.sitecore.net/reference/using%20sitecore%20query/sitecore%20query%20syntax.aspx
I think I'd look at creating a custom field type that inherited from multilist and overriding the logic that pulls items based on the data source - then you can filter it programmatically however you want. There are various blog posts available on that subject, such as http://gettingtoknowsitecore.blogspot.com/2010/03/custom-fields-part-1.html
You could also consider putting categories as subitems under each blog to drastically simplify the whole thing - then you could simply use a relative query or an ancestor-or-self query without anything custom.