Hide breadcrumb only on 404 page - css

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 }
}

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;
}

how do i locate files in wordpress by inspecting element a particular element in google chrome?

I want to change some particular line on my Wordpress site which I cannot change in the customization. How do I locate a certain line with inspect element in chrome?
My website is www.Artiana.io and I want to edit this line:
"<h5 class="subscribe-description">Learn more</h5>"
Please, can anyone help me out?
Let me show you how you can use WordPress's hints in html body class to find the php file:
WordPress gives hint in the HTML's body tag that which particular template was used to display this page.
In your case we have following classes in the body tag:
<body class="home page-template page-template-page-templates page-template-page_front-page page-template-page-templatespage_front-page-php page page-id-466 custom-background wp-custom-logo blog-post">
Now there is a specific class which ends with php, which tells that template was used by your theme to build this page. i.e. page-template-page-templatespage_front-page-php
Now it could mean that in your theme folder:
/wp-content/themes/hestia/
There could be sub folder or folders called: **page-template/page-templates** and inside it is page_front-page.php PHP file, which is being used to create this layout. See if you can locate the code you are trying to modify there.

Diazo - on error show message (when you get the content from a page)

Can we skip a diazo error and prevent page crash by replacing it with a nice message in page? Something like: Your content you want to show in this page is not created or published. Please check this section /source/homepage-content-sample-section.html.
<!-- Images slider section -->
<replace css:theme="[data-diazo='my-images-slider']"
href="homepage-content/homepage-images-slider" method="document"
css:content-children="#content-core" />
<drop css:content="#content-core [data-diazo='my-images-slider']" />
I have a page in Plone for each section in Homepage, that contains html code easy to edit. The problem is if a page is missing or private the homepage is broken.
Calling user-managed contents with href in a Diazo rule is like playing Russian roulette. If the page is not existing, there is not way to prevent the page crash.
The best approach is to call a developer-defined URL in charge of retrieving the content if it exists and that will just gently return nothing if the content does not exists.
Rapido is a very easy way to do that (you create a Rapido block which can be called like that: href="##rapido/myapp/blocks/get-content-for-my-homepage", this URL will always work, your page will never crash whatever the users have done with the content).

Episerver 5 child pages urls export MVC

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);

open graph image is loading properly for some pages but not others

This is the open graph image I want to load on all my pages shared on Facebook. It is loading properly on some pages and on others it is choosing a random image from the page. Below is the OG URL. I am using Drupal CMS for my site. All the proper code seems in place.
http://www.vaeducationoxnard.com/sites/default/files/styles/square_thumbnail/public/Charter%20Square%20Logo.png
This is because, facebook sends the whole new request to the url you are passing and because of this it gets the image from og:image in which you have passed the default image. To overcome this, try to aadd the image parameter in the url you are passing
Ex. your/url?imgToShare=
And in the main page from where you set the meta tags, add one condition
<?php
if(isset($_REQUEST['imgToShare'])
{
<set the meta tags for image you want>
}
else
{
<meta tag with the default image>
}
?>
This helped me.
Please comment if you have any doubts.

Resources