unable to access a child page by its node alias

Muhammad Kaleem asked on April 16, 2019 19:58

i have created a page type destinations & simple container type(without fields) asia and then another pagetype country the structure of my pages in pages application are as follows:

destinations>asia>india and i give UrlPattern to country pagetype in this way "/destinations/{%NodeAlias%}" and getting 404, please anyone can help to access the country page in this way, any help will be highly appreciated.

Thanks

Recent Answers


Brenden Kehren answered on April 16, 2019 20:40 (last edited on December 10, 2019 02:31)

To start, I'm unsure why you'd create container only pages if you plan to navigate to those pages later on. This doesn't make sense at all. What I'd suggest is creating 2 page types one for country and one for continent. Then, you'd create all your destinations in the content tree under /destinations. Like so:

/destinations/asia
/destinations/australia
/destinations/europe

Then under each continent, you'd add a country like so:

/destinations/asia/india
/destinations/asia/china
/destinations/asia/cambodia

In this example above, there is no need to create URL patterns.

If you plan to use data from elsewhere to dynamically create your page, you can then create URL patterns on the /destinations page like so:

/destinations/{Continent}
/destinations/{Continent}/{Country}

Then in your web parts on the /destinations page you can use querystrings to get the values like so in your where condition:

ContinentNameColumn = '{% QueryString.GetValue("Continent")|(default)novalue |(identity)GlobalAdministrator%}'

1 votesVote for this answer Mark as a Correct answer

Muhammad Kaleem answered on April 16, 2019 20:46

Thanks Brenden Kehren for your quick response, i'm using kentico12 mvc, for the seapration purpose i have created this container, for example countries of asia will be under asia container and countries of europe will be under europe container, if i change this container type to page type will this work?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 16, 2019 20:53

Ok that makes more sense then. What I specified above is irrelivant to MVC, it would have worked with Portal without issue.

From an document query standpoint, you'd want to use NodeAliasPath which will hold the path in the content tree you have setup. Using URL patterns in the front end Kentico application won't help at all, you need to set these routes all up in your MVC app.

1 votesVote for this answer Mark as a Correct answer

Muhammad Kaleem answered on April 16, 2019 21:01

i have added route like this way

routes.MapRoute( name: "DestinationsCountry", url: "Destinations/{pageAlias}", defaults: new { controller = "Destinations", action = "DestinationCountry" } );

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.