I need to add a webform to my page-home.tpl but I'm really new on Drupal so I need a really clear help...
I'm using DRUPAL 6 and I have created the webform.
I would like to add the webform to my custom template just adding the php code to the tpl file. My webform id is id="webform-client-form-20".
Can you help me ?
Thanks a lot
The quickest (not necessarily best) way to do it is using a combination of node_view() and node_load():
$nid = 20; // Node ID of the webform.
$webform_node = node_load($nid);
echo node_view($webform_node);
You'd be better off loading that into a variable in a preprocess function than outputting it directly in the theme but this should work for your purposes.
Related
I am new on drupal, Can you help me to make custom template in drupal and how i call this?
I want to create a custom template and how i call this in my node
and also please describe how the block call in under page content, there is any shortcode for block?
Hi create YouThemeName folder and put it in /site/all/themes/.
In theme folder create file YouThemeName.info and insert it:
name = YouThemeName
description = YouThemeDescription.
package = Core
version = VERSION
core = 7.x
// Regions
regions[header] = Header
regions[content] = Content
regions[footer] = Footer
And you new template is ready. For more inforamation please visit Drupal.org and read documentation.
Looks like you want to override some Drupal template? As of Drupal 7.33 there is theme debug mode, to enable just add row to your settings.php: $conf['theme_debug'] = TRUE; and then just open page for which you want to override template and open developer tools there(Use Ctrl+Shift+I (or Cmd+Opt+I on Mac)), you will see something like this http://take.ms/XOXZt and can identify which template to create and how to call it, more you can read here https://www.drupal.org/node/1089656
Creating custom template in drupal is super easy, you can create a file name like node--[type|nodeid].tpl.php and place it in templates folder of your theme.
Remaining drupal does the magic, your can do your stuffs in the custom template file. Similar way to create for custom block tempalte file too.
For more information you can check this url:
https://www.drupal.org/node/1089656
we are planing to create a CMS with zf2 and doctrine orm .
actually we are concern about our cms templating
we want our system works with several templates and easily change between themes via admin
and creating a new templates should be easy for end-users developers
we want an advice or suggest for how to build templating system that :
there is a core module and there a lot sub modules with their own phtml
so where to store theme1 phtml and where to store theme2 phtmls ...
any suggest or advice please
thanks
I encourage you to take a look at Twig, its the best template engine I have seen so far :) It does take some time to learn Twig syntax, but its well worthy if you look at what you get :)
I cant yet write comments, so I wrote this as an answare.
Hope this helps. Trust me, the Twig is the way to go. Joust look at his documentation for more specific details how to use it!
EDIT:
The problem you are trying to solve has nothing to do with template engine. You can do that with any template engine. You can do it even with plain PHP if you want.
I built web application where users can register, get their own sub domain, and there they can build their webpage. Change theme, edit text, add pages. Simple CMS functionality.
The easiest way to do this is to have themes folder, where you would store themes, like this:
themes/
- themeBlue
- css/
- images/
- js/
- html or views/
- themeRose
...
Now this is where you would place all your themes, every theme has its own folder with images, css, js files...
And then you would have users, and every user would be able to choose and change theme.
That information would be stored in database. You need to store that user Jack is using themeBlue. You can do that as you want. You can event put this in users table like user_theme column.
Now when someone visits site, you first query database to see what theme is that user or creator of web using. And then you load all that files from current theme folder. And populate html files with data stored in database like in any other CMS.
This is the simplest implementation. You could for example, store css and html files in database :)
Hope this answers your question.
Good luck with that, I almost gone mad building my system :) I ended up with writing my own PHP MVC Framework joust to accomplish what I wanted.
if you activate another module in the application.config.php which has the same views and layouts (same folder structure and filenames) it's viewscripts and layouts will automatically be used when it's loaded after your core module.
so you could simply make your application.config.php dynamic to load the active template module which only contains the view folder. this would be a simple and effective solution without any other libraries.
additionally you can use an asset manager like assetic to also provide images, css etc. inside of your (template-)modules. (have a look at zf2-assetic-module, I wrote my own assetize-module based on assetic to fit my needs...)
Sina,
I do this in my Application->Module.php onBootstrap
$ss = $serviceManager->get('application_settings_service');
$settings = $ss->loadSettings();
$serviceManager->get('translator');
$templatePathResolver = $serviceManager->get('Zend\View\Resolver\TemplatePathStack');
$templatePathResolver->setPaths(array(__DIR__ . '/view/'.$settings['theme'])); // here is your skin name
$viewModel = $application->getMvcEvent()->getViewModel();
$viewModel->themeurl = 'theme/'.$settings['theme'].'/';
In this situation I have this structure in my view folder
view/
default/
application/
error/
layout/
zfcuser/
red/
application/
error/
layout/
zfcuser/
The $viewmodel above injects a variable into the layout for the themeurl in the public_html folder /theme/red/ with all assets for red
Access in layout.phtml -> themeurl;?> in a viewscript layout()->themeurl;?>
I am still working out my Dynamic Views. Right now I have a BaseController and all my ActionControllers extend it. It has a render() function that builds the required views but not sure its going to be scalable hoping to try some placeholder ideas.
application_settings_service is a Settings Service that gets settings for whatever domain was used to call the system and builds an array accessible via any service aware part of the site. Thats a whole different post and it may or may not rub MVC peeps the wrong way
I know your question is marked answered just thought I would share
Eric
I know there are a ton of different custom template files like page.tpl.php and node.tpl.php etc. But is there a way to make a custom template for a specific node ID? This doesn't work node-3.tpl.php, but is there a way to accomplish this?
UPDATE CODE
function phptemplate_preprocess_node(&$vars) {
$vars['template_files'][] = 'node-' . $vars['nid'];
}
For Drupal 6, the page template is 'page-node-3.tpl.php' and read the manual at http://drupal.org/node/1089642
Drupal 7, page--node--3.tpl.php : http://drupal.org/node/1089656
Thanks #Clive and #asiby.
Make sure that you rebuild the theme registry. Failure to do so will result in Drupal completely ignoring the node-x.tpl.php file that you will add.
I am trying to integrate the awkward showcase into my page--front.tpl.php. My first idea was to create a custom content type (slideshow image) and then a view that prints a list of those images. I was able to create the view and set it to be available as a block... but I have no idea how to include that block via my .tpl.php file. I don't want to just use the content region because it displays a bunch of "hello welcome to $sitename" messages that I couldn't figure out how to remove.
Also, what is the naming convention for views blocks? The machine name for the view I want to create a template of is called 'front_page_slideshow'
There's a way of adding views programatically,
the easiest way is using "views_embed_view()" http://api.drupal.org/api/views/views.module/function/views_embed_view/7
$view = views_embed_view('view_name', 'display', $args);
print $view;
For render a block (any kind of block) use this simple script I created:
https://gist.github.com/4001153
I would create a region['slideshow'] in your template. Then you assign the view that you've already created into it as a block. If you want to get really simple, till you figure how to drupal properly, you can just hack your page--front.tpl.php file and use include('yourslideshowfile.php'); to simply include your file there.
I'm trying to give my webform node a readable name to make it easier to find and edit.
I'm able to use the template I created called "webform-form-12.tpl.php" and theme that, but I want to use something like "node-webform-form-athlete-of-the-month_submit-your-athlete.tpl.php". The path I gave this webform is "athlete-of-the-month/submit-your-athlete". It's not working with any names I've tried. I'm using a node preprocess function to add template file names. I've tried these so far:
node-webform-athlete-of-the-month_submit-your-athlete.tpl.php
node-webform-form-athlete-of-the-month_submit-your-athlete.tpl.php
This one: "node-athlete-of-the-month_submit-your-athlete.tpl.php" uses the template but the form is not there.
What version of webform? The latest Webform 2.x and 3.x should support the use of TPLs.