How to link to an individual web content item in Liferay? - liferay

Let's say that I am using an AUI Carousel to display a news item slideshow.
This is a typical slideshow - a series of images with overlay text and each image/overlay text links to a web content article for the site's news.
It seems that with Liferay 6.2, it's only possible to link to a page containing the article rather than the article itself.
How does one link to an individual article?

The solution here is to use a Display Page; starting with Liferay 6.1, there is the concept of Canonical URLs (see here).
In order to use this, you need two things:
an asset publisher page (in my example here, the page is called News)
when creating the web content item, set the Display Page to the above (News)
Now the content item can be referred to via: http(s)://<site-url>/-/<web-content-item-url-title>
So, if I have a web content item with the name Come Join Us For Lunch, and a site url of http://my-site.com/, the canonical URL for this web content item will be http://my-site.com/-/come-join-us-for-lunch
However, you should always get the actual url-title from
JournalArticle.getUrlTitle()

Related

Editing Sharepoint Online HTML content using Client Object Model

We have a sharepoint online site with a good amount of pages that have href links to a shared in-house network server. Example: file://servername/sharedFolder This way when the user clicks the href - it directs them to the location in the file explorer if using IE or Edge.
Due to server maintenance - we needed to rename the server. So now "servername" is "servername1". This messes up all the links on the sharepoint site.
I need to iterate over all the pages on the sharepoint site, and fix the hrefs.
I apologize im very new to sharepoint so maybe im missing something very simple.
What i have right now is the following:
using (ClientContext ClientWebContext = new ClientContext("site"))
{
ClientWebContext.Credentials = new SharePointOnlineCredentials("username", ss);
Web web = ClientWebContext.Web;
Microsoft.SharePoint.Client.File file = ClientWebContext.Web.GetFileByServerRelativeUrl("page");
ClientWebContext.Load(web, w => w.Title, w => w.Description, w=> w.Lists);
ClientWebContext.Load(file, f => f.Length, f=> f.ServerRelativeUrl, f=> f.Name, f=>f.);
ClientResult<System.IO.Stream> str = file.OpenBinaryStream();
ClientWebContext.ExecuteQuery();
FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ClientWebContext, file.ServerRelativeUrl);using (FileStream filestream = new FileStream("C:" + "\\" + file.Name, FileMode.Create))
{
fileInfo.Stream.CopyTo(filestream);
}
}
The idea was to download the page - parse the html and update the hrefs, then write the page back out to the sharepoint server. But when i view the file that has been downloaded it doesnt contain any of the html that is actually on the page.
If i go to a page, select "edit", then select "Edit Source" I can view and edit all the html in raw format.
I guess the question is - how do i get this html and how do i pro grammatically update it.
EDIT:
A typical sharepoint page contains a table, cells & text inside of those cells. The text then contains links to the server I was talking about above. The sharepoint site is essentially being used as a wiki for new employees and a resource for existing employees to find information quickly. It doesnt contain many complex web parts and embedded code, mainly just a table, cells and text.
Thanks,
-John
Yeah, I don't think this approach will fly.
Again, different types of SharePoint pages have different web parts. Modern SharePoint site page, Wiki page, web part page. They all can have text web parts and/or page elements that can hold HTML, and in some, the WYSIWYG default presentation can be changed to a HTML editor. Then there are also list web parts, link web parts, and all kinds of stuff that can have an underlying link URL.
But these page elements are SharePoint artifacts. The page elements and their contents are stored in an internal SharePoint database. The page chrome and styling is also stored in different parts of the database. The SharePoint server processes the different parts that make up a page. On the SharePoint server side, these page elements then get translated and rendered into HTML that is served to the end user's browser.
You cannot take this rendered end result and expect to use it to change the underlying source of the HTML.
You need to get to the source. Again, what exactly that source is depends on the type of page used. Just because it is "in SharePoint" doesn't identify the page type.
Sorry, I know this is not what you want to hear, but if you want to manipulate SharePoint content, you need to acquire an understanding of what SharePoint is and what its moving parts are.

How to change orchard blog home page list view/summary view

I have Orchard 1.7 setup with blog recipe.
The home screen display a list of blog posts.
I want to override the way the content is displayed in summary view. I could do this for each parts. But my styling is such that I need to wrap title, body, and meta tags with a special div when ever the display type is summary.
The problem is:
After shape tracing I understood that the template used in the home page (summary) is same as the detailed one.
Content.cshtml
For detail view I want to use the default core-> Views/Content.cshtml but for summary I need to supply my own. How can I do this?
OR
How to write a driver/widget to the home page. I know how I can do this for parts/fields/modules but I don't have an idea on how to create a driver for Blog home page.
Whenever I add a widget to the homepage the default blog post list still get displayed.
Just create a file called Content.Summary.cshtml in your theme. This will target all summary views, so if you have more than just blog posts on your site you will probably want to have Content-BlogPost.Summary.cshtml.
I wrote a small blog post on Item templates in Orchard if you are interested... http://arkleseizure.net/what-the-hell-is-an-item-template

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 Group Sub Pages in Orchard CMS

I'm wondering if there's a way in Orchard or a plugin/module that anybody knows of that will let you create subpages in Orchard such that when I go to content -> pages I'm not looking at a huge list of pages; I want to see a list of main pages with their sub pages grouped under them?
Is this possible?
On a related note...when you're working with a navigation widget (that uses a menu) I want to highlight the main item as a current nav item when I'm on a "subpage".
For example, my Company page has a separate leadership page that I would want to highlight the company nav bar item (since leadership is a subpage) when you're on it.
Any recommendations would be very helpful. Thanks!
There are many ways you could achieve this in Orchard:
You could use blogs and blog posts:
Blogs are parent pages
Blog Posts are child pages
Blog posts can have URL that consists of blog's URL which you can use to create your menu.
You could also use Orchard.Lists module which enables you to add Containable and Container parts to get the functionality similar to blogs, but for other content types. You can check the tutorial on how to do it here
You could use Orchard.Taxonomies module to create a hierarchy of pages and use taxonomies for your menu
Lastly, you can do this manually by using ordinary pages and giving them hierarchically named slugs (for example parent page could have URL /parent and child page could have slug /parent/child). You could then manually create a menu that is hierarchical and consists of pages you created and use slugs to highlight your parent pages in menus..

How does browser detect embedded web content from a HTML page?

Once a browser gets the main html page, how does it know which are the embedded content should be request again from web server, and which are only external links? Is it based on type of tags, e.g ?
If so, could someone give me a reference of what these tags are?
Thanks.
The HTML5 spec defines the element category "Embedded content":
Embedded content is content that imports another resource into the document, or content from another vocabulary that is inserted into the document.
It lists the following elements:
audio
canvas
embed
iframe
img
math
object
svg
video
Elements like link or script (both in Metadata category) can also refer to other ressources that user-agents (browsers, screen-readers, …) are free to link to or include or do whatever they want to do with it. For example, browsers like Firefox or Chromium will (by default) load and "apply" CSS that is linked within the link element, that has the rel value = stylesheet. Browsers like Lynx or w3m won't do that. They simply ignore that link.
For link, HTML5 states which link types "are links to resources that are to be used to augment the current document, generally automatically processed by the user agent":
Two categories of links can be created using the link element: Links to external resources and hyperlinks. The link types section defines whether a particular link type is an external resource or a hyperlink.
Maybe also consider the style attribute (for inline CSS), which could include a background-image url.
Yes, the tags help browser identify the resources to load. After downloading/retrieving the content the browser determines what to do with the content based on the content-type header in the response.

Resources