Episerver 5 child pages urls export MVC - asp.net

I am trying to export specific pages child pages into some kind of list. The purpose of this is because I am updating a web site which is on episerver 5 to the new which is on episerver 7. The links should be updated as well, meaning I want to redirect all the current child pages to go to the new parent link. And I don't want to use a catch all since I want to show the 404 page if the child page doesn't exist.
Example:
Parent page, current web:
http://localhost/newssection/
Parent page, new web:
http://localhost/news/
All child pages from the current web should redirect 301 to the parent page for the new web.
Example of child pages:
http://localhost/newssection/what-is-going-on/ should redirect 301 to http://localhost/news/ and so on...
I want to build a script that generates all these redirects with rewrites for all the parent pages I select. How can I achieve this the best way?
Thanks in advance,
Mike

There are obviously nearly endless ways of achieving this, but two viable options are:
1) Use rewrite rules in IIS (if you can use a common pattern or have a limited number of redirects)
2) Create a custom redirect, potentially as an HTTP module or an action filter on your page controller base class, and redirect to a URL set on each page
For option 2) you would probably add a new property called something like "LegacyUrl" on your base page type. It would be used to specify which old URL the new page is replacing.
For each page request resulting in a 404, look up the URL among the legacy URLs and redirect with "permanently moved" status code.

I would create a simple page and do something like:
var children = DataFactory.Instance.GetChildren(new PageReference(IdToParentPage));
foreach (var child in children) {
Response.WriteLine(child.URLSegment); // this is only the segment for the page, not the full URL
}
And from that create rewrite-rules in web.config or add to it to some 404 module if you have that.
If you need the full URL you can get it with the following code:
EPiServer.UrlBuilder url = new EPiServer.UrlBuilder(child.LinkURL);
EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, child.PageLink, System.Text.UTF8Encoding.UTF8);

Related

Custom 404 Basic Page in Drupal 7 Has Blank Title Tag

I have created a basic page in drupal 7 to use as my 404. I configured under Configuration -> System -> Site Information to use this page and when an unknown URL is entered, it does indeed display this page while maintaining the unknown URL. For SEO purposes, I really want Page Not Found in the html title tags but it is missing. If you go directly to the basic page, the title tags are correct. Is there a setting somewhere that I am missing?
I used the metatag module's configuration for the 404 page to achieve the desired title tags
When you create a any page, you will get node id of the respective page.
In your case, you need to copy page.tpl.php file and rename new file with your node id like for example : page--node--1.tpl.php
Now, put below code in your newly created template file and clear the cache.
if($title) {
print $title;
}

Hide breadcrumb only on 404 page

I created a custom node for 404 page and added the path /node/83 to the site information. And new node is applied. I can't hide (display:none) .breadcrumb to apply to it. I'm trying to do it through css injector and have it apply to only the 404 page. I'm checking it with inspect element and it works and there is only .breadcrumb and i don't see any additional classes that looks like page-404. I added new rule to CSS injector and I don't know what is the path to apply it only to 404 page:
path to not found page
or another idea is to use class that is only applies for 404 page, if there is any by default:
add a class to not found page
Thank you for any help.
Don't hide it in CSS but avoid sending the breadcrumb to the browser.
See https://drupal.stackexchange.com/questions/260304/prevent-path-based-breadcrumb-in-theme-or-dont-show-breadcrumbs-for-403-404-r
Open the 404 page where you'd like to add the CSS rule. Open web inspector and look on the body or html tag for a class that is specific to the page. Something like page-404
Then in your custom CSS add
.page-404 .breadcrumb {
// Your styles
}
This is drupal so Im not to sure if you can do a php check to see if its a 404 page or even if the 404 page has a css class on the body tag if so i would go that way (inspect the element if you can see a class on body that references an error page just target the breadcrumb that way eg, body.error .breadcrumbs {display: none;} if this is not possible take a look at this
https://www.drupal.org/node/15366
Basically this tells you how to make your own 404 page.
Create two nodes, one for each kind of page error (403 and 404).
Determine the ID number of the node you wish to redirect users to. One way to determine the node's ID number is to visit the node and look at the number after the last slash in your browser's address bar. This is your node's ID number.
Now enter the paths to your nodes in the appropriate boxes on your error reporting settings page. For example, if the node ID number for 403 error codes is "83," you would type "node/83" into the "Default 403 (access denied) page" setting.
Drupal 6 mysite.com/admin/settings/error-reporting
Drupal 7 mysite.com/admin/config/system/site-information
Because you are creating nodes, they will show up in the tracker and popular content blocks and anywhere else real nodes would be display. If this isn't acceptable, there is a contributed module called Custom Error that avoids this problem.
Also consider the Drupal 7 contributed module, Redirect 403 to User Login. Which provides redirection to the login page and configurable 403 and 404 error messages.
EDIT
Ok go to sites/all/themes/themename/template.php and edit this file.
add this to the top
function themename_preprocess_page(&$vars) {
// Adds a Custom 404 page
$header = drupal_get_http_header("status");
if($header == "404 Not Found") { ?>
<style>
.your-custom-css-here {}
</style>
<?php }
}

Creating personalized URLs (PURLs) in Wordpress

I need to create a site that will allow for a unique user-identifying number to go in be appended to the URL.
So for instance
test.com/12345/about/
will load the page with slug 'about' (not redirect to it).
I have tried the following:
function custom_rewrite_basic() {
add_rewrite_rule('^([0-9]+)/', '/$matches[1]', 'bottom');
}
add_action('init', 'custom_rewrite_basic');
But it does not work, any prefix to the URL redirects the page with or without the block of code above.
So in my tests
test.com/23423423/about will re-direct to test.com/about which is not what I want.
Is what I am trying to achieve possible? If so, could anyone offer advice as to how I would best go about implementing it?

created node id in the next form?

I have a content type which is created using CCK's(Establishment). I have used $form['#redirect'] to redirect the user to another form that is generated from a custom module(Beers). My requirement is i need to save the created Establishment node id with values of beers module. How can i do this?
I installed Rules module and in admin/rules/trigger/add i created new rule and and added rule element as IFconditionCreated (content is Content Type) DO page redirect and in page redirect i set To as node/add/bears and in the next text box i added below code.
n_id=nid; ?>
Everything worked Great.

How to get $_REQUEST[] through URL in wordpress

Hi I have a problem in my site on which am working on localhost. I am using pretty urls in my localhost.I have custom page templates for all the sites every page has a different header and footer and the content in it.
I used
<div class="btn_container"></div>
<div class="btn_container"></div>
The Problem I have to get request parameters in wordpress and query the db against these request query string parameters. And also it does not route to this page template.
I have hard-coded URL like in the above divs.
Please help
Could you simply grab the link id from the URL like
$link_id = $_GET['page_id']; // this would equal 1038 from your example link
A page template is assigned to the page through the admin panel:
1. Go to the admin panel
2. click on pages
3. choose the page you have created
4. choose the template on the right hand side.
Simply linking to it does not assign the template to the page like your example is showing.
Try
$pageId = get_query_var( 'page_id', 0 );
get_query_var() only retrieves public query variables that are recognized by WP_Query.
This will not work with your custom variables.
If you want to get your custom variable check wordpress documentation - https://codex.wordpress.org/Function_Reference/get_query_var

Resources