Orchard - access a content type through different URLs so they use different views - orchardcms

I'm trying to create a CSS documentation library in Orchard. I want to save a description, CSS snippet and HTML snippet against each content type. The first view would show the description and CSS and HTML code written out. The second view would show a preview of what the CSS and HTML look like rendered.
cssdocumentation.com/content/item1
cssdocumentation.com/content/item1/live-preview
I've created the content type and the first view. But I'm not sure how to create the second view. I can see if I can create the alternative URL I can use the Url Alternates module to create an overriding .cshtml
To create an alternative URL I've looked at the autoroute module but this only allows you to adapt a single URL (unless I'm missing something?) and I've looked at Alias UI but this forces me to manually create an alternative URL everytime I create a content item.
Is this possible in Orchard without writting too much C#? (I'm a frontend developer so I only dabble in the behind the scenes stuff)
Thanks for any help

Best solution is to do this within your own module. But as a secondary option instead of having a second page, combine this content with your first page and hide it with CSS. When the user clicks a button to navigate to the next step render the CSS/HTML result on the same page. You can do this in many ways, here are a few ideas:
Render the CSS/HTML result out straight away on the same page but hide it. Show it when the user clicks a button
using jQuery to render the result on the client side. More dynamic if you allow editing of the HTML and CSS.
Redirecting the user to the same page with specific url parameters which you can pick up in your alternate to modify the output.

Related

How to only get the "title" and "main content" of a page using puppeteer?

I'm trying to create a clone of getpocket.com for learning. On that app, every saved link gets converted into a markdown; and it seems like the it's a filtered content with only the page title and body without headers, footers, etc.
I could get the page's title using puppeteer api thru different means:
using page.title()
or get the page's opengraph "og:title"
But how do i get like the summarized version containing only the main content of the page.
Note that i don't know beforehand the "css class" of the main content since i'm planning on just entering a url in a textbox and scrape that site from there.
I have found what i've needed for this scenario.
I used the Readability.js library for making webpages readable by removing some certain html tags. Here's the library.
This library is what mozilla uses behind the scenes when rendering their reader view

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.

Orchard CMS 100% unthemed html page

We have a requirement to use the content zone of Orchard CMS to enter in html for a full screen landing page. We managed to get an unthemed page type using the Downplay.Orchard.Layout selector. The problem is that in using the content zone orchard automatically wraps html, head and body tags around it. We want to remove this content so we essentially have a blank page to start off with and then we can create our own html to display on the landing page. Is this possible to do for a single page and if so what would be the best way to do this?
You can have a URL alternate or you can use the new Disable Template part (1.8, i think)
I have done lots of URL alternates in the past. Pretty easy.
Just remembered, a question like this: Using Alternatives for Document.cshtml in Orchard CMS
removing the Wrapper (Document.cshtml) from your (Layout-url-...) and adding a new one, should do the trick.
And it might be better to use the placement.info, but thats my opinion...
Suppressing Wrappers and Placement.info

Custom information pages not using SEO friendly URLs in OpenCart

I am having issues with the opencart layout override feature. I have created a new information page and I set the layout override to "test". The route for this layout is "information/test". The controller is in the right place, as is the template. I gave the new page the seo-friendly url of "test-page".
My issue is that if I type in "domain.com/test-page" it will get there, but it uses the regular information layout instead of my customized test layout. I can type in domain.com/index.php?route=information/test&information_id=119 and it will now show the page with the right layout.
Is there a way to have it go the customized layout page (domain.com/index.php?route=information/test&information_id=119) when I type in the seo-frindly URL that I created when I created the new information page.
My issue is I am trying to add a carousel to just one information page, while still using seo-friendly URLs.
actually what you coded in template file test.tpl is not a layout, its actually a page accessed using test.php controller , and that page can be opened by accessing url domain.com/index.php?route=information/test&information_id=119 as you already mentioned.
How to create layout then ?
You have already created layout named test by going to System >> Design >> Layouts, now go to module carousel and a module to test layout at say content-top , set your test-page layout override to test and now go to domain.com/test-page and you will see carousel at the top, this is how layout works. what you previously doing was creating a new page by duplicating information controller and template.
A similar discussion on opencart forum Here

How to include custom CSS or Javascript on a Content Item in Orchard

Sometimes I want to add some custom CSS or Javascript to a page but the HTML editor doesn't handle this gracefully, even when using text dialog.
I could use an alternate view but then I have to upload the view file to my host every edit.
Any ideas?
Ok, I found a module (Vandelay.Classy) that does exactly this.
http://orchardproject.net/gallery/List/Modules/Orchard.Module.Vandelay.Classy

Resources