Creating links to organization/community pages in Liferay 6 - url

Lets say I have am Organization object. How do I create an url that points to that organization's public pages?
There is a class NavItem that creates links to given layouts, but which one the "front page" is undocumented (among everything else). Then there is PortletURLImpl that can be used (in convoluted way) for this at least as long as user is a member of the community.

A URL to a Liferay page obeys to the following format:
/[web|group]/[group-friendly-url]/[page-friendly-url]
The first part decides whether to link to the public (web) or private (group) pages. You can also change these strings inside portal.properties (search for layout.friendly.url.private.group.servlet.mapping and layout.friendly.url.public.servlet.mapping). In that case you should use the configured strings instead of the default ones.
The second part is de friendly URL of the group. As you know, each Organization in Liferay is associated with a Group. So you can do something like this: organization.getGroup().getFriendlyURL()
The last part is the friendly URL of the page you want to visit. If you don't specify any page, Liferay will automatically redirect to the first page of the group.
In your case it would thus be sufficient to do:
String url = "/web"+organization.getGroup().getFriendlyURL();
Good luck!

Related

Umbraco This document is published but its url would collide with content (error)

I am new to Umbraco CMS. I have every thing setup but get the following error. (Highlighted in red.)
How do I set the URLs in Umbraco. Or fix them?
The alias (short URL) of a page is defined by the name that you give the page in the input bar at the top of the page:
If you have two pages both named Weddings, then they will conflict; you can only access one view when visiting /weddings/.
In order to correct this, simply come up with unique names for your pages, such as Indoor Weddings and Outdoor Weddings (for example).
While these page names are mostly for organisation within the Umbraco CMS, they will be reflected in in URL, so I would recommend choosing something semantic.
Note that you can also set the page's URL manually with the UmbracoUrlName (and UmbracoUrlAlias) routing property if need be.

Suddenly new URLs with "table/"?

I'm running a simple site based on Joomla. The SEF URLs are defined by SH404SEF and look like https://[domain]/[category]/[sub category]/[article title alias].html. In some cases there is a 1-to-1 relationship between category and article but in some cases one category has several articles.
Suddenly I have URLs requested following https://[domain]/table/[category]/[sub category]/. Not only does these new URLs in some cases create 404s, they also view my articles in the wrong way and when there is not a 1-to-1 relationship between category and article the link adds several articles on one page.
The correct non-SEF URL ends with &view=article and the new, uncorrect non-SEF URL ends with &view=category. I have no table/ in my correct URLs, neither in any internal link, in the articles' html code, in menu items nor in my sitemap.xml. I've discussed this with the few extension providers I am using and none of them see their extension as doing this request new.
Is there any way to find out what is making these requests?
I cannot make a redirect for these URLs since all of them do not
correspond to one article, but several. Can you see any risk with
making a rewrite rule that puts a 410 on all URLs that starts with
table/?
This is actually a misconfiugration in sh404SEF. Here's what to do:
Login to the backend of your Joomla site
Go to the sh404SEF configuration
Set the field "Insert Content Table Name" to "No"
Flush all URLs and clear your Joomla cache
This should do it.

How to rewrite prestashop friendly urls? (not the htaccess file but url for each product)

For some reason in my shop some of the friendly urls are mixed up. For example I have a product with name "White wine glass 280 ml" and the friendly url is "250-red-wine-glass-300-ml.html". If I go to product edit page and select SEO and click generate URL than the url is corect and all is fine but I don't want to do that for each product in shop.
How can I do that for all the products at once?
I tried finding where are the urls stored in db to delete them and hope presta would autognerate them but I couldn't find where they are saved.
You have to do an override of Dispatcher.php class or use hookModulesRoutes in a Module.
Just create overrides/classes/Dispatcher.php and modify original methods/variable to get what you want to achieve here. You will have to modify how pages are grabed by PHP/Prestashop by altering the script getting the (for exemple) product ID and make a search inside your products url_rewrite to get the good one.
Honestly this is a tought job and lots of modules available are doing it very well, you should have a look as some are very cheap (less than 20$).

Misconception regarding Master and Home document types

I currently have these Document Types:
Master
Home
News
About
I allow Home at root, so when I visit / it will show my home, instead of going to /home. Then I create a new Content for Home. That means my Content/page layout looks like this:
Home
News
About
Since I want all my pages to be /news and /about, but still have / be my Home, I therefore allow News and About to be children of Home (in the permissions tab). This is great and all, because I can then create properties on my Home Document Type, which the other document types will inherit (such as SEO).
Well, both great and bad. If I want my Home page to have properties that none of the other pages will inherit, I cannot do that now, because all the other pages inherits from my Home Document Type.
How am I supposed to achieve this:
Have a Master.cshtml file, which has #RenderBody()
Make a property on Home which will not be inherited by all the other Document Types
Make sure / is my Home content page
The only way I can think about this, is by allowing my Master Document Type at root, then replace my Home Document Type with Master and have the same structure as now, but basically have Home as a child of Master (in the content page). This would mean / is set to the Master content page, which I do not want. However, URL rewriting /home to / should solve my issue, right?
Is there a better way? Is this the way to go? Let me know how you guys would structure a page like this, so I can create properties for all pages and while separating Home from the rest of the pages.
Thanks!
You should use composition of document type instead of "nested inheritance". This new feature has been made exactly to solve this kind of problem:
You can add to every document type the SEO document type to add the SEO tab, but add some specific properties only to some document types. No need to change the tree in the content section.
For example you can create these document types:
seo (only used for composition in other document types)
shared (only used for composition in other document types)
home (with composition of seo + shared ) + some specific fields for this document type
news (with composition of seo + shared) + some other specific fields for this
about (with composition of seo and no need for the shared for this particular document type)
Note that these are flat on the document type tree and there is no need for master document type because you will add everything in common via composition and not inheritance.
The content tree will look exactly the same:
Home
News
About
Take a look at http://letswritecode.net/articles/document-type-compositions-in-umbraco/ for some examples
One approach would be to use an Umbraco internal redirect to display the Home page content whenever the root / URL is requested.
Add a new Content Picker property to your Master DocumentType and give it the alias umbracoInternalRedirectId. This is a reserved property alias, much like umbracoNaviHide and umbracoRedirect, and it will cause the selected page's content to be displayed without performing a URL redirect.
On your Master page select the Home page using your new property. Now whenever you browse to / the Home page content will be displayed.
Your Home page will still be accessible via the /home URL so you should either use a canonical tag to prevent duplication of content or you could implement a URL rewrite from /home to /.

Maintain parameter info in the request path for all pages instead of the subdomain

I seek some guidedence here ... ( I'm not sure if this is the best title )
At the moment I prepend a "server name" to the url like this:
server10.example.com
This works fine, except that I need to handle all the subdomains on the IIS and I'm not sure google are happy about jumping around from sub to sub to sub, when it seems the links to the other servers.
I'm kind a hoping for a nice way to archive this wioth asp.net mvc.
Most pages are related to a "server" ... there are however a few info pages, contact, home that dont really need a valid "server" name ... but could just be "na" for not available, but the name need to be maintained, if there is already a selected server, when a user are keeps browsing the site. This needs to be as transparent as possible when I need to create the links to the diffenrent pages.
I could extend the Html Action() extensien to automatically add the selected "server" from the previusly request to the page.
In the format:
/{serverParameter}/{controller}/{action}/{parameterInfo}
And if no server is selected, just add "na" as the {server} placeholder.
I'm not sure if more information is needed, but please let me know if ...
I tired of extracting the selected server from the domain part and the other way also seems better, I just can't think of a good way to structure this ...
Updated
90% of all the pages are about a server that the user select at some point. Could be server10, server9, server20 ... just a name. I want to maintain that information across all pages, after the users has selected it or else I just want it to be f.ex: "empty".
I mostly looking for an easy way of doing this or an alternative ... atm I'm prepending the serverParamter to the url so it ends up being: "serverParameter.example.com".
I want to end up with something like
http://example.com/{server}/{controller}/{action}
instread of
http://{server}.example.com/{controller}/{action}
If I understand your question correctly, you just wish to group different collections of content together above the controller/action level. If that's the case, have you considered using ASP.NET MVC areas?
Just right-click on your project, and choose Add -> Area.... Give it a name (what you're calling "server"), and then you can add content, your own controllers, actions, etc. Under this area. You will automatically be able to access it via /AreaName/Controller/Action/etc.
I went with the already impemented routing in ASP.NET MVC.
{server}/{controller}/{action}
When creating the links it takes the set value for {server} and places the value when generating URL's, so I only need to supply controller and action in the #Html.Action helper method ... this could not have been more easy.
I'm not sure why I did not think about this. One just gotta love routing.

Resources