created node id in the next form? - drupal

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.

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

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

Custom Pods.io detail page

I am attempting to create a custom template page for a details page for my Pods.io 'research_faculty' pod.
I have the url going currently to /people/details and it does go to that page but I created a 'details' page that I have assigned a custom template to display the information that I want. Problem I am having is that its treating the last part of the URL as a page and Wordpress is saying page cannot be found. So it would be /people/details/wally-kolcz. How can I use the past part of the URL as the way to pull the person's details and populate the template page rather than WordPress trying to use it as another page and defaulting to the single.php template?
Pod (Advanced Options)
Custom Rewrite Slug: people/details
You can use pods_v( 'last, 'url' ); to get the last segment of the url. If you put that in a variable you can use it to build your Pods object.
// get current item
$slug = pods_v( 'last', 'url' );
// get pods object for current item
$pods = pods( 'pod_name', $slug );
See this tutorial for more information: http://pods.io/tutorials/using-pods-pages-advanced-content-types/
Um create a pods page and on the Enter page URL section enter /people/details/* so that it responds to /people/details/+ anything. Also in the slug section u can try putting {#url,2} If it doesnt work. Also go to the advanced options of your advanced content type and in the detailed page URL enter pod_name/{#permalink} though that may not be necessary but try that and test it again.Make sure the pods page also has a pod to refer to and that it points at your php details template

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