Theming node add form - drupal

I want to theme this page node/add/classified.
I tried creating page--node--add.tpl.php, page--classified--add.tpl.php, page--node--classified--add.tpl.php refreshing cache all the time...Nothing works
I tried also implementing hook_theme() and hook_preprocess_page().

If you want to create a tpl file for a particular content type as you mentioned in your post "node/add/classified", then I would suggest, you should go with the tpl name like this
Drupal 6 : page-node-add-[content type].tpl.php
Drupal 7 : page--node--add--[content type].tpl.php
in your case, this would be (assuming your Drupal version is 7.x):
page--node--add--classified.tpl.php
Hope it will help you.

Related

how can i display contact us page on front page drupal 8?

I am creating scratch theme in drupal 8. Problem is occurred now i want to show contact us block display front page in footer right corner. I had used contact form module but it opens new page. I also used Contact block but result is nothing my concern is that how to does this?
If any one knows, tell me i do not have more knowledge about drupal thanks.
You can use this:-
$block = module_invoke('module_name', 'block_view', 'block_delta');
print render($block['content']);
You define a path to your form admin/content/webform.
Then you define your home page in Site Information admin/config/system/site-information.
More easy, contact block + twig tweak module, get the frontpage node theme sugestion, in my case node 2, -> node--2--full.html.twig and theming it.
content.field_my_field for fields and
drupal_block('mymachinenamebock') -> drupal_block('contactblock') got by the twig tweaks module
You can include the contact form to the footer region by modifying your theme's your_theme_name.theme file.

Drupal 6 theme add / edit content form

Drupal 6 theme add / edit content form
In Drupal 6, we can add new content type "content-type".
We want to theme /node/add/content-type by template file.
We want to theme the edit form /node/$nid/edit of this content-type also by template file.
How to do this?
For this you need to understand the naming convention of tpl files in Drupal. This link will help https://www.drupal.org/node/1089642
According to documentation,
"http://www.example.com/node/1/edit" would result in the following suggestions:
page-node-edit.tpl.php
page-node-1.tpl.php
page-node.tpl.php
page.tpl.php
Either you can try adding content-type in the naming as suggested(I have not tried it personally), or if there are few customization to be done, adding a check like
<?php if($node->type == 'content_type_name') ?>
over available variables in "page-node-edit.tpl.php" will also do.

Place an Edit Button on the view node page in Drupal 7

I don't use the Drupal Tabs because they interfere with my CSS but I need the functionality of the Edit tab to be on that screen so that a user can edit the node after reviewing it.
Any ideas on how to do this? Functions? tpl placement? Thanks!
You can do this in a custom module as follows.
In yourcustommodule.module you implement hook_preprocess_node(). In there you check if the user has permissions to edit the node and you set the edit link.
function yourcustommodule_preprocess_node(&$vars) {
if (node_access("update", $vars['node']) === TRUE) {
$vars['edit_link']['#markup'] = l(t('Edit'), 'node/' . $vars['nid'] . '/edit');
}
}
In the node.tpl.php template in the theme you print the edit link if it is available.
<?php if (isset($edit_link)) : ?>
<p><?php print render($edit_link); ?></p>
<?php endif; ?>
If you do not have a node.tpl.php template in your theme folder than copy the one from modules/node.
If you're using the Views Format "Fields", one of the fields that you can add is "Edit Link." It's pretty flexible; it will tell you what text to display in the link. That's probably the preferred option.
If you're not using the "Fields" format, it gets trickier, especially since you're already interfering with some basic drupal styling. I'd need more information about your View and your skill set to recommend a method that doesn't cause more problems.
As a sidenote: I learned Drupal theming from the outside in, and used to use CSS that would interfere with the underlying drupal mechanics like tabs and contextual links. I've moved away from that; I find very few cases where I need to interfere with native styling-- and for those I can use custom .tpl's to get around.
EDIT: Ah. If you're not using views, a custom page .tpl is probably the best way to go. If you're not familiar, the structure for any node edit link is '/node/<NID>/edit' (for clean URL's) or '/?q=node/<NID>/edit' for old-style URL's. Depending on how your path aliases are set up, '/<url-alias>/edit' may work as well but the previous ones are more reliable.
This link on drupal.org gives a few options.
I think u can write a theme file(.tpl) for u specific case and theme page in whichever way u want

Hooking basic pages in drupal 7

I have few basic pages in drupal 7, named about, contacts. I tried to make page--about, and style it, but it doesnt work. Any advice on how to force hook basic pages?
In your themes template file you can get template suggestions. This was you can check there isnt anything weird going on. The following will dump out suggestions for templates.
You need to use the following:
function YOURTHEME_process_page(&$vars) {
var_dump($vars['theme_hook_suggestions']);
dsm($vars['theme_hook_suggestions']); //if you have Devel
}
You should install the Devel module, this helps alot with theming.
First make sure you're using the correct machine name for your content type. Go to content types and copy it from there.
Copy the node.tpl.php file from root/modules/nodes/ to your theme's templates directory.
Rename the node.tpl.php file to node--MACHINE_NAME.tpl.php.
Clear the cache in admin/performance/. This is important.

Drupal - Replace the home page

Hi
Anyway to stop people browsing the Drupal home page and redirect to my specific html page?
Thanks you
For Drupal 7 you need to use page--front.tpl.php
If your theme doesn't have a page.tpl.php that you can copy, then copy it from your base theme if you are using one or:
modules/system/page.tpl.php
This should be placed in your custom theme folder in (assuming this is not a multisite):
sites/all/themes/my_theme
I tend to structure my themes as follows:
my_theme.info
templates/html.tpl.php
templates/page/page--front.tpl.php
templates/node/node.tpl.php
templates/block/block.tpl.php
css/style.css
But it doesn't really matter where it is, it will be picked up after a cache clear.
If you have specific HTML page that it is on the server and doesn't generated from Drupal, the most easy way is to use Drupal goto.
How to do it? open your template.php and search for page_preprocess function it should look like that:
YOURTHEME_preprocess(&$variables, $hook) {
if( drupal_is_front_page()) {
drupal_goto('yoursite.com/yourpage.html')
}
}
change YOURTHEME to your theme name and clear the cache.
The real Question why should you use static HTML file for your homepage? I would create some article or view for homepage and change it as I like with theming... It is much easier than any other alternative.

Resources