Custom 404 Basic Page in Drupal 7 Has Blank Title Tag - drupal

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

Related

Drupal 8: Is it possible to get title from path or route name?

Is it possible to get Title of a page from the url or route name.
I have a router name for example: view.topics_landing_page.page
Or the same page has a path: /topics
By using either path or Route name, I wants to get the title Eg:- Topics.
Is it possible?
Thanks in Advance.
The only way to get the page title of any URL/route would be to actually request the page and see what the title is. The reason is that any module or the theme could alter the title from what it normally would be, like fx metatags module.
To get the title of the current page you could do this:
use \Symfony\Cmf\Component\Routing\RouteObjectInterface;
$request = \Drupal::request();
if ($route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)) {
$title = \Drupal::service('title_resolver')->getTitle($request, $route);
}
But another thing you could do is override the breadcrumb.html.twig template. This will render the template wherever you place the Breadcrumb block.
Drupal 8 has core functionality for page title.
In block structure you can see "Page Title" [Link : your-domain/admin/structure/block]
You can use this one on any region you want to show title of current page.
Clear you cache after set this block on region..!!

How can i edit the default drupal node view page

I am trying to edit the default page view of a node in Drupal and i found the file called node.tpl.php but even if i change it, the node page on the site isn't updated...
So how can i update the node view page so i can added some text, images etc.. ?
I guess that node_show function () { } is the one that displays the node but the code there doesn't give me enough detail on where the HTML is created so i can it
You need to copy the file to your theme's templates folder and clear the cache out before you can use this file. The original file should be at root/modules/node/
You can also set a template up for a specific content type by copying the default node.tpl.php file and renaming it to node--CONTENT_TYPE_MACHINE_NAME.tpl.php

blank page with my custom region - drupal 7

i have add my region to a info file:
regions[mine] = Mine
then i have created a view with a block display and I add this block to my custom region.
Last, I invoke in my node.tpl.php with:
print render(block_get_blocks_by_region('mine'));
but I have a blank page with html:
Please any help??!!
Why are you invoking that in your node.tpl.php file? This doesn't make any sense in the context. It appears that you want to have a block inside of a region - this is configured in the administration pages, not theme files.
If you are getting a totally blank html page rendered then you likely have an error in your PHP somewhere - Drupal has a habit of swallowing PHP errors without any visible warnings.

Create an Iframe from a Drupal Website

I have a drupal website. I want to generate an Iframe with content from my drupal site, that other sites can embed.
How I think this can be achieved:
Method 1: Create a php script that is autonomous from the drupal engine.
Import the configuration file and hence gain access to the database. Generate the content as a standalone webpage. Distribute the url of this script as the iframe's source url.
Problems: cannot provide drupal functionality within the iframe such as interaction with logged in user.
Method 2: Create the iframe from within drupal.
Create a new module that defines a menu entry using hoom_menu (the url for the iframe). Define the content of the iframe from the callback function of the menu entry. Then Somehow assign a custom page.tpl.php theme for the desired iframe url so that only the content of the iframe is rendered without all the other page elements (blocks, menus, footer, etc.).
Any comments especially for method 2 will be greatly appreciated! :)
I have done exactly this, just this week!
I created a custom module that outputs only the content that I want (using hook_menu()). Then I created a page template (page-mycustommodule.tpl.php) that only has
<?php print $content; ?>
within the <body> tags.
That was basically all. To find out the name that your page template needs to have, use the devel and theme_devel modules, then just click on your page and it will tell you which templates it looked for.
One thing to look out for: any links in the iframe will only change the contents OF THAT FRAME, so when your module creates links, use the proper target to make the parent page jump to the new URL:
l('link text',
'node/' . $mynode->nid,
array('attributes' => array('target' => '_parent')));
I found the answer by Graham very useful. Unfortunately I don't have enough reputation on this site to add a comment so I will have to put my comment in an answer.
5 years on, the information has changed slightly:
The module theme_devel now seems to be called devel_themer instead.
In D7, the template naming pattern is slightly different with 2
hyphens: page--[front|internal/path].tpl.php (see docs)
D7 templates are slightly different based on render arrays, so the template will need to be something like print render($page['content']);
method 3
you can use this module https://www.drupal.org/project/entity_iframe that allows you to create IFRAME READY webpages
install it and go to the display settings of you content type that you want to use as iframe content admin/structure/types/manage/CONTENTTYPE/display
choose the IFRAME view mode and choose the fields you would like to be shown
and then use url like this domain.com/entity_iframe/node/NID and you will have a display with no extra headers footers etc ...
By default a sample EMBED/IFRAME code is provided to the admin under each node the settings
<iframe width="100%" height="300" src="domain.com/entity_iframe/node/96" frameborder="0" class="entity_iframe entity_iframe_node" id="entity_iframe_node_96" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>
The settings in admin/config/system/entity_iframe control some of the details of the embed code
For complete control of the theme used you can use in combination with https://www.drupal.org/project/entity_iframe_theme
What do you exactly need to iframe?
A node? A block? Should it be static or dynamic?
You can simply create a node with a php filter and generate the iframe output.
Then you can put this output between <pre> tags to display it as code that users can copy/paste in their site.

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