Rendering ContentItems collection to multiple Zones - orchardcms

I have a Taxonomy term that I am using to display a number of associated Content Types in my site (Products, Blog Posts, etc).
I have created an Alternate to display the Term, but the ContentItems collection contains multiple content types (Blog Posts, Products, etc).
These means ALL items that use the Term_Part shape are rendered in the same zone. The linked Blog Posts need to be displayed in a completely different Zone to my linked Products.
At present I am iterating the ContentItems collection and filtering on the ContentType, but is it possible to use Placement.info to display Parts in multiple zones?
Or better still, control what ContentTypes within the ContentItems collection should be displayed in which Zones?

You should be able to use something like this for each of the content types you want to place:
<Match ContentType="BlogPost">
<Match Path="/MyTaxonomy/*">
<Match DisplayType="Summary">
<Place Parts_Title_Summary="/RelatedBlogs:1"/>
</Match>
</Match>
</Match>
Note the / which means that it is being placed in a global zone (Layout.cshtml). In that file add:
#if (Model.RelatedBlogs != null)
{
#Zone(Model.RelatedBlogs)
}
This will leave behind the <li> in the ContentItems collection. My work around is creating TermPart-[MyTaxonomy]Term.cshtml and leaving it blank, but that only works if you are not leaving any Content Items behind.
As a note, I added in the Match Path without testing it out so hopefully that works. Before adding the Match Path I was running into an issue where the Blog Title was being dispatched to that zone whenever the blog summary was being displayed.

Related

Get listitems from Current Site

I am trying to create a Page Layout, that should have a lookup field. Lookup field should always get populated with a list's items.
This list will exist in all subsites, so whereever I create this page, list should get populated with listitems from current site.
I tried using site column lookup field, but it always point to list under top site and not the current site.
Any suggestion on how to make it work or better alternative? Thanks!
Let me know if I can provide more info.
The most straightforward solution I can think of is using a cross site lookup column and creating a seperate fields for each subsite. However, you will need to create and use different Page Layouts for each subsite.
You can use http://sp2010filteredlookup.codeplex.com/ for cross site lookups.
Solution 1 - Use http://sp2010filteredlookup.codeplex.com/
Use filtered lookup solution. So let's say you have your custom Page Layout and custom Page Content Type.
Every time you create new subsite, you should remember go to Pages list settings and edit Page Content Type by adding cross site lookup (with the same field "internal name").
So you still have one Page Layout (and one Content Type). But for each Pages library instance, Content Type contains diff fields (but with the same Internal Name). It will allow you run CAML queries and other things needed without any problems.
Solution 2 - develop custom sharepoint field type.
In edit mode, control will render "dropdown list" and populate data from list instance that is on current subsite. In the field settings you can have relative list url.
Solution 3 - hidden text field / js snippet solution
Page Content Type can contain hidden text field (it can contains selected field value in json format for example). Develop js snippet that will handle all the logic (rendering in edit/view mode, saving etc) and put it on Page Layout (aspx).
I would suggest to use solution #1 or #2.

CQWP Lookup Fields Multiple Site

I don't know what I am doing wrong but it is driving me mad.
I am searching through Blog Sites and displaying posts including the PostCategory.
I have exported the CQWP and updated viewcommonfields to include PostCategory,Lookup
I have edited the itemlist.xsl to display #PostCategory
When I use a CQWP on a single Posts list the PostCategory is displayed (show items from the following list). It doesn't seem to matter which posts list I choose, it works fine.
As soon as I change the query to Show Items from the Following Site and all subsites or Show items from all sites in this collection, the category is no longer displayed. I have tried typing allsorts into the Fields to Display under PostCategory, e.g. PostCategory, Category, Category [Custom Types], but all to no avail.
What am I doing wrong?
Thanks
Stewart.
I'm not able to test it right now by myself, but try to use Guid instead of field name.
For example I have similar case, but need to show post title for comment. I use
{a131e489-d3d6-4f0c-a152-a3beb89f12be},Lookup;
in CommonViewFields, and
<xsl:variable name="PostTitle">
<xsl:value-of select="string(#_x007B_a131e489_x002D_d3d6_x002D_4f0c_x002D_a152_x002D_a3beb89f12be_x007D_)" />
</xsl:variable>
in XSL.
Also you can specify which lists in which sites should be queried by filling 'ListsOverride' and 'WebsOverride' properties of CQWP
http://www.glynblogs.com/2011/06/querying-specific-lists-with-the-content-query-web-part.html

Create a list of pages in Orchard

Lets say for example, I have a list of products that each have it's own page... in what way can I create a single page that will list each product as it's contents as a list (with hyperlinks)? Not really sure how to do this directly in Orchard - or will I need to create a custom page / widget? Thanks for any help... new to Orchard and not sure how to tackle this.
You have a couple options. I believe the Orchard gallery at orchardproject.net has a module called Simple Commerce that may solve your problem. (it's simple so it might not)
(In the following section, I've tried to boldface the terminology words that are 1) are crucial to understanding how to use Orchard and 2) helpful in finding your way around the dashboard)
Another option may be first creating a Content Type--probably one named Product with some Fields describing an individual product. Price, SKU and description come to mind, but you'll be better able to describe your own products. Each Content Type in Orchard can be associated with any combination of Parts. You may have to research which ones you actually want for an individual product, but I'd recommend:
Body (this could replace the Description I suggested above) You could include any amount of HTML/script in this section to make your individual product pages look fancy!
Common (this has to be added when Containable is used)
Containable (this will allow the items to be listed)
Route (so you can link to a specific product)
This gives each product its own slug (URL)
Tags (to allow products to be categorized)
Now, you need to create a new List from the dashboard so you can display the products together (and inherit other features like pagination, etc). Be sure to select the Product Content Type in the Contains drop down list.
Then, you can start creating your Content (your Products) one by one. In the dashboard, click the new Product item and describe each new piece of Content.
Finally, you can link directly to this new List using the Products List's *slug*. You could (and might want to) add the Products List to your main navigation menu. Clicking the Products List and checking the "Show on main menu" box will automagically add a navigation button directly to this page. You could, of course, link to this List from anywhere using the slug (also found on the list's edit page)
This page, from the Orchard documentation pages describes more things you can do with a list of content like modifying the layout of the list, placing content fields in different places and even converting your products to widgets which you could use to display some promotional product offering in a special spot on your site.
I highly recommend reading through at least the documentation provided on the Orchard site to get a good grasp of what this CMS can do out of the box and what you would need to write custom code to accomplish (which you could do in this case, but Orchard can handle it out of the box)
Hope this helps!
Two ways to do this:
http://orchardproject.net/docs/Creating-lists.ashx and http://orchardproject.net/gallery/List/Modules/Orchard.Module.Contrib.Taxonomies

How did I get multiple lists with the same name in my SharePoint site?

I have a SharePoint site that's being created from a custom site definition. The site definition has the following Features:
A custom content type.
A custom list template whose schema.xml file refers to that content type.
A list instance feature which refers to my above list template feature.
During the site provisioning process, I activate each of these features (each is at the SPWeb level) through C# code in the order above. My resulting site looks as I expect and seems to work fine, but it has the weird artifact that the "all site content" page for my site shows my custom list twice.
My list acts okay -- its item receivers fire correctly and only once. In SharePoint Manager (SPM), I also see the list show up twice, and when I expand the tree to look at the attributes, they appear identical across the two lists (even the list items inside the lists). I suspect that I may be fooling myself and SPM might be just looking at the same list twice, while some actual rogue list lies in the dark shadows of my site.
So, what could have gone wrong here? How could I have created multiple lists of the same name? How can I correctly create this list? And how can I properly clean up the weirdness in existing sites that exhibit this behavior?
Edit:
In response to Michael Stum's question, I created this console app to loop through the site's lists and get the ID:
using (SPSite site = new SPSite("http://myserver/projects/myproject"))
{
using (SPWeb web = site.OpenWeb())
{
var lists = web.Lists;
foreach (SPList list in lists)
{
Console.WriteLine(list.ID + ": " + list.Title);
}
}
}
This code shows my list twice -- same title, same ID.
Another edit:
I looked in the SharePoint content database for this site, and I executed this query:
SELECT * FROM AllLists where tp_webid = '<my SPWeb guid>'
This reveals that there's only one actual list with the title and GUID that I retrieved from my C# code above. So what is causing these multiple entries to show up when I'm browsing through my site?
I've come across with this issue several times. It's not a bug, most likely you have semantic errors in the elements.xml of your list template.
If a list definition contains more than one default view, the symptoms you described above will show up. Check the elements.xml file of your list template and make sure you don't have more than one View-Element with in it.
Kind regards
Ramon
I suggest you put a call in to Microsoft, this sounds like a bug.
P.S. without seeing the actual solution that creates the list we can't determine what's happening, perhaps a feature got activated twice...
Today I came across this issue and after reading the above answers I came up with an easy solution. Just create a new Default view and the Document library will show up normally again.
Kind regards,
Thijmen Groenewegen
P.s
I "created" the same two libraries by migrating the library from one place to another. At the old place the library was only showed once. If I look at the default views on that library two views are checked as Default.
Groenewegen is spot on.
I ended up with two Announcements lists on a site after I ran Export-SPWeb on a subsite and then Import-SPWeb to move it to a new site collection.
To fix it, I created a new default view for the list, All List Items, selected one of the two All Items views and deleted it, and the issue was fixed.
The Announcements list was being displayed twice on the View All Site Content page, and the data was being shown twice when viewing the All Items page.
Also, an intermediate step that you have to take before creating a new default view, is to open the list or library and add "?contents=1" to the URL so you can open the web part maintenance page and "Close" one of the duplicates. You have to do this because the web part ribbon will not show up on the Announcements page if multiple web parts exist, and you need the ribbon to access the view drop down and create a new view.
Have you tried with:
list.RootFolder.Name
(which shows the "internal" name - a part of the url)
list.Title shows the displayname (which can appear twice or more).
This could also be the explanation why you get multiple lists. You have maybe added them with the same displayname but dirrerent "internal" names?

Content Query Web Part and Deleted Occurrences of Events

I have a content query web part showing 3 events for todays date on our Intranet homepage. However, when a user deletes an event from a recurring series, SP changes the title of that event to "Deleted: [original title]". My content query web part still shows these and I don't see a way to filter them out.
For my list views I get around it with a field and a formula in that field of the following.
=IF(ISNUMBER(FIND("Deleted:",Title)),"Yes","No").
However, that field isn't available to me within the CQWP filter drop-down.
how does one prevent these deleted occurrences from showing in a CQWP?
UPDATE: This is a publishing page BTW.
While you can perform the filter via XSLT, it may be preferable to do so in the CAML query itself. This article from Microsoft, How to: Customize the Content Query Web Part by using Custom Properties, shows how the CAML Where clause is constructed (and may be modified). Good luck!
Have you tried the DataFormWebPart (DFWP) before? It is basically the most basic of databound webparts, but strangely the most customizable as well.
To try it out, open SharePoint designer and create a dummy aspx page to work on / play around with. Then open the datasources pane and find the list you want to use. then click on that list and select "view data". Drag the appropriate fields onto the aspx page. You now have a (very) basic grid displaying your data.
The cool thing is though, all layout is xsl driven, so completely customizable. You can even make the xsl reusable by switching to source view and cut and paste the xs,l into a separate xsl file. To then use this file instead of the inline xsl, after moving the inline xsl, change the DFWP property xsl (that contained the inline xsl) from
<xsl><!-- .... this is where the moved inline xsl used to be... --></xsl>
to
<xsllink>/server relative url to xsl file</xsllink>
The only remaining problem is that the DFWP's datasource is now bound a single list. To do roll-ups cross site collection (if you have say multiple event lists you want to include), you need to change the DFWP's SPDataSource's select query and datasourcemode. How to do that is explained here.
Now to address your actual question: (after my blatant plug of the underappreciated DFWP :-D) The DFWP's SPDataSource basically uses either an SPQuery or an SPSiteDataQuery (depending on the datasourcemode) to retrieve the data, and you can do way more filtering wise. Either in the CAML query itself or by just filter out the unneeded rows using something like the following:
<xsl:if test="not(contains(#Title, 'Deleted:'))">
<xsl:apply-templates />
</xsl:if>

Resources