Faulty pages created by SiteDefinition - sharepoint

I'm creating some pages using a SiteDefinition, the markup looks something like this:
<File Url="Page.aspx" Name="$Resources:SiteDefinitions,PageName;" Type="GhostableInLibrary">
<Property Name="Title" Value="$Resources:SiteDefinitions,PageTitle;" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/Somepage.aspx"></Property>
<AllUsersWebPart WebPartZoneID="WebPartZone1" WebPartOrder="1">
-- webpart data here
</AllUsersWebPart>
</File>
The page is created as expected, but it's somewhat faulty. If for instance I click Edit Page and then click Publish (without actually editing anything) I will get this error:
"This Page has been modified since you opened it. You must open the page again."
I will get this error approx. every second time I try an editing action.
If I manually create a page using the same page layout everything works as expected and this error does not show up.
Does anybody have an idea what could be wrong?

I too create a Page using the above method only thing I found missing in your code is that I used to have a title in the PageLayout as
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/Somepage.aspx, Your title"></Property>
This should not be the cause, but you can try it, Also refer the articles this or this

I think you're right with using PublishingLayoutPage. I came across this article today while searching for this error caused by something else. It describes your same issue although the person in the article was not inheriting from PublishingLayoutPage and had not specified the PublishingPageLayout property. When they fixed this it worked.
This doesn't directly help you, although I did notice in their article that they are specifying the ContentType property. Have you tried specifying this? As you can see your complete code, are there any other differences you see from the article or additional information from the comments?

Okay, I (kinda) got this working now.
The guy who had made the ONET.xml had put a reference to the page layout in the Url attribute of the element.
Like I wrote in a comment earlier I tried making the page layouts inherit from TemplateRedirectionPage. Instead I now made an empty default.aspx file that inherits from TemplateRedirectionPage and changed all my page layout files back to deriving from the PublishingLayoutPage. And then I added the PublishingPageLayout element below every element.
Funny, or oddly, having a refence to the page layout in the Url attribute and not having the PublishingPageLayout element at all is actually valid. It doesn't make sense, because it will produce these faulty pages, but SharePoint actually accepts it and spits out all the pages defined in the ONET.xml
Only thing left now is that since I made the above changes, when I manually create a new page based on a page layout every default webpart (as defined with AllUsersWebPart) is instantiated 5 times. Really don't know where this behaviour is coming from, but at least it's not as serious as not being able to edit/publish my pages :)

Related

Liferay 7.4: How to create a configurable web content article footer?

I need to create a footer in a Liferay-project, that can be modified from the instance. I've been trying various things in my footer-code and instance, but haven't figured out how to do it.
Any content inside the footer can't be touched and in page edit mode, Liferay says "This area is defined by the theme. You can change the theme settings by clicking more in the Page Design Options panel on the sidebar". I didn't get any help from Page Design Options either. Is there a way to do this?
I found the answer after hours of work and searching and want to share it with everyone here. The working solution was found here, in one of the comments.
You need to write some code (I use Freemarker/ftl) and then configure the site pages a bit, but here's how it works:
Put a new setting inside liferay-look-and-feel.xml:
<settings>
<setting key="footer-article-id" value="" configurable="true" type="text"/>
</settings>
This will create a new configurable option in page options, allowing you to input the ID of the web content.
NOTE: <theme> might get underlined red "The content of element type "theme" must match". This still prints everything correctly, but the tags are given in a wrong order. Inside my <theme>, I have <template-extension>, <settings> and <portlet-decorator> in that order, which removes the error.
Assign a variable in init_custom.ftl (cleans up the footer-code):
<#assign footer_article_id = getterUtil.getString(themeDisplay.getThemeSetting("footer-article-id"))/>
And then add this to the footer-code, to create the spot, where the content is visible:
<#liferay_journal["journal-article"]
articleId=footer_article_id
groupId=page_group.groupId
/>
After this, everything should be ready code-wise.
Create a Web Content for your footer. In the creation screen, there's an ID on the panel on the right. Publish your content and grab the ID.
Finally, go to Site Builder --> Pages and click on configuration from the top bar (behind three dots). You should see the input field like in the first picture: That's where you add the ID.
Save the settings and your web content should now be in the footer.
Hope this helps!

Can I render all zones to an HTML string in a controller method

I'm trying to render the HTML for a content item to a string from within a controller action. Technically I just want to get the "body" part of it without any header/footer stuff. I want to do this so I can get a content item rendering the way I want once, and then display it as a normal orchard page OR by requesting the HTML for the content item via ajax to display it in a div in a JavaScript app. I don't want to have to manually render everything in the JavaScript as that would be duplicating the layout logic I already did. I want to re-use the bulk of the server side rendering so any changes are reflected in my normal orchard page and my JavaScript page. I've been digging into the code and searching everywhere and have gotten close but not all the way there.
I found these:
How to render shape to string?
Using FindView in Orchard
In my controller I have:
var shape = _contentManager.BuildDisplay(contentItem);
Using either of the two methods above, I can render that shape to an HTML string in my controller. All was golden. I was getting the body of that page and using it in JS. Then, I changed a placement file:
<Place Parts_Common_Body="Content:1" />
was changed to:
<Place Parts_Common_Body="/AsideFirst:1" />
The body moved where I wanted it (AsideFirst) in my normal Orchard page but disappeared from the HTML retrieved using the two methods above.
If I look at shape.Content.Items after the BuildDisplay call, I can see the item for the body is no longer there... why is it not rendering all the zones? Or, I guess a more specific question is why is the BuildDisplay method not building the complete shape? Is there a way I can make this work?
I tried a million different things and eventually got this working. Not sure I totally get it yet, but I think the problem had to do with the fact that I was using shape.Content and I'd moved stuff out of the Content zone. And maybe when I was looking at what the BuildDisplay method was returning I was just not looking at some newly created zone that actually did had the stuff I thought was missing. Clearly I need to learn more about zones and shapes... Anyway, I have a new zone called "MainInfo" now that I created in a placement file. I get a MainInfo property on the main shape returned form BuildDisplay and pass shape.MainInfo to the view rendering code and all seems to be working well now.

Why does my Sharepoint WebPart deploy (nominally), but is still not available for adding to a page/form?

I've created and "deployed" my latest Web Part (Visual Studio grins from ear-to-ear, and tells me, "Deploy succeeded").
But when I go to our Sharepoint site, and my "sandbox" page, and Edit it, I do not see the WebPart. As the Elements file shows, it should be available from the "Financial Affairs Forms" category:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
<Module Name="PostTravelExpenseWebPart" List="113" Url="_catalogs/wp">
<File Path="PostTravelExpenseWebPart\PostTravelExpenseWebPart.webpart" Url="PostTravelExpenseWebPart.webpart" Type="GhostableInLibrary" >
<Property Name="Group" Value="Financial Affairs Forms" />
</File>
</Module>
</Elements>
However, that category is devoid of the "PostTravelExpenseWebPart" I expect (or at least hope) to see there:
What might I be omitting?
UPDATE
I even went so far as to, while in Edit mode on the Web Page, expand the "Upload a Web Part" section below "Categories" after selecting one of the "Add a Web Part" links. I didn't know exactly what to upload (when browsing for a file, the File Dialog doesn't clue you in on what file extension it expects), so I, on a flayer, tried uploading PostTravelExpense.ascx
It accepted it without balking, but I do not see it anywhere (nor do I know why just the *.ascx file would be enough, but again, which file does it expect?) It doesn't allow me to upload the entire project folder.
UPDATE 2
In response to the comment below, note that The project's Assembly Deployment Target" property is set to GlobalAssembyCache
By comparing a working project with this one, I was finally able to get it to deploy without the "A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe." add-time error msg.
What I had to do was check every place in the working project where the primary namespace was referenced, and make sure that the corresponding namespace in the previously-unworking project was referenced in those same places
This required not only changing some of the files visible in Visual Studio's Solution Explorer treeview, but also two that I only was able to load into the editor by searching for strings they contained, specifically:
The ***.spdata** file, which I loaded up by searching for "SafeControl"
**Assembly.Info**, which I loaded up by searching for "AssemblyTitle"
That sure was a lot of hand-wringing and head-banging and pitiful whin[g]ing for something that one would think would automatically be taken care of by the IDE - when a namespace changes, make all the necessary changes, or at least notify the coder and offer to do so! Or, barring that, at the very least give him a better clue than "A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe." when the WebPart to be plopped onto the page proves unploppable.

No route patterns are currently defined for this Content Type

Using the Orchard cms tutorial http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-4
I have completed half way down the page until the
<Placement>
<Place Parts_Product_Edit="Content:1" />
</Placement>
When I run the application and click 'book'...the 'Sku' or 'Price' does not appear as it should (on the form) and a message appears at the top of the page...
No route patterns are currently defined for this Content Type. If you don't set one in the settings, a default one will be used.
I have tried google but cant find anything relevant
Would anyone have any ideas as how to resolve this? thank you
Orchard 1.6... Did a clean install and was going through an example and came across this error too. I "Resolved" this by removing and re-adding back in AutoRoute.
This is a bit old but I resolved this by adding a "Title" part to my content type.

MODX: I added a resource page and now all my links are broken

A client wanted me to add a page to his Modx website. I am only a Joomla/Wordpress guy but I figured I would take a stab at it.
Here were my steps:
I clicked "new document", gave the page a template, a name, a parent, then pasted in some dummy text and hit save.
Now, all of my links look like this: http://www.myurl.com/modx/contact.html
edit: Actually that is how they are supposed to look according to google. They just simply are not linking to the page any longer.
My blog link still looks like this: http://www.myurl.com/blog (and it is the only link on the page that works)
I cannot delete the resource that I created under any circumstances. Modx just crosses it out in red and there is no option to permanently delete it, that I can find.
edit: Got that part solved... :)
Thanks for your help, I am trying to fix this before the client realizes it is broken.
You specified base tag in head? Like this: <base href="http://www.myurl.com/modx/" >.
And to fully remove the resource you need to press the trash icon on top resource panel tree.
Getting rid of the resource group assignments sorted out the issue, and the site is now fully accessible again.

Resources