By jghyde on
Having trouble with theming the input for for a content type I created in CCK.
I am using CCK 4.7 phptemplate on Drupal 4.73
The content type is called simply, "business"
Here is my phptemplate.php:
<?php
/* Pass the form template for Directory Listing through themes. added jghyde 9/24/06 */
function simplex_node_form($form) {
if ($form['form_id']['#value'] == 'content_business_node_form') {
return _phptemplate_callback('form-business', array('form' => $form));
} else {
return;
}
}
?>
And the template file is called form-business.tpl.php. Inside it, I placed this code just to see if it was getting parsed:
print '<strong>The CCK form of the type Business</strong>';
And I don't get any love out of this. It does not appear to be processing the form-business.tpl.php and giving me the output in that file. Instead I still get the default form that was always there.
Does anyone have ideas on why this form is not being overridden by template.php?
Comments
quick one..
hi jghyde,
this isn't a complete answer..but, seeing nobody else chipped in...it might spark some ideas..
the following template.php snippet loads up a business_edit.tpl.php layout file when someone is adding a new business (CCK) node.
You'll need a different snippet for when someone is EDITING a business cck node...(the cck.module uses the default node_form so you need to *only* override
node_formfor that specific content type).hope that helps..
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Dub, this worked!
Dub-
Thank you so much for the reply. This argument worked. Here is a modification I used:
1. I deleted the previous CCK node type and made a new one called "businesses" (In my recent version of CCK 4.7, it is referred to as content_ with the underscore, not content- with the dash. The node name is thus content_businesses.)
2. Modified your code, which was really right on in parsing the arg(x)s, and placed this into template.php. It is IMPORTANT for newbies to understand that template.php will not work if you have more than one php enclosure ( that is
...) or if you have any spaces or invisible characters before the <?php starting tag):If you have mod_rewrite enabled, the arg() values are in the uri in the address bar of your browser. For example, http://www.example.com/node/add/content_businesses yields:
3. Created a businesses_edit.tpl.php file and placed inside it:
And guess what? I MADE IT!
Now I have to figure out what variables are available for themeing. Anyone have a quick one-liner?
Thanks Dub, you are the man!
Joe Hyde
jghyde
Local News Platform Built on Drupal
http://sanangelolive.com/
quick one..
here's the template.php snippet for calling your businesses_edit.tpl.php layout file when you're EDITing a Businesses CCK node.
To answer your question about which variables are available....you'll need to check out the forms api or the Forms API Quick reference
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
custom module
I have gotten alot of mileage out of doing it this way. I create a module called sitemodule.module (you can call it whatever you want) that contains site-specific code that is just easier to put into a module than in the theming. Then you can just hook into form_alter and do as you will with any form. Try this:
I am intersetd in this
I am intersetd in this approach... thgrough this way can i add a button in the cck input form which basically does the add funcatioanlty... that will basically make a copy (per click of button) of two cck fileds(i have one tectfiled and one dat filed) in the form itself.... mostly like multiple functionality in ccK fileds but i wnat taht on click of a button....
Any Pointers and help is really appreciated.
Related full description is here http://drupal.org/node/158097
-Abhishek
Bangalore
...
Shouldn't that be "content-business_node_form" (dash, not underscore) ?
It depends on what CCK version you use. The newer CCK defines the content type as "content_business" (not "content-business"); Since the latter is a valid PHP identifier, it lets you define the function theme_content_business_node_form.
put a
print $form['form_id']['#value']statemetnt at the head of that function (and you can at least see whether it gets executed).quick one
was looking for something else earlier and spotted a node form template module which sounds like an add-on to help theme node forms for you.
haven't tried it, but, it sounds like something that might be useful.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Add a "Add <Content Type> button"
Can i add a button in the cck input form which basically does the add funcatioanlty... that will basically make a copy (per click of button) of two cck fileds(i have one tectfiled and one dat filed) in the form itself.... mostly like multiple functionality in ccK fileds but i wnat taht on click of a button....
Any Pointers and help is really appreciated.
Related full description is here http://drupal.org/node/158097
-Abhishek
Bangalore
what is the procedure for drupal 6 ?
hello
this looks not working for drupal 6.
the theme's documentation is too much complex for me.
do you know a simple way as this one to theme cck edit forms for drupal 6 please ?
6.x solution
+1
what is the procedure for drupal 6?
+2
Drupal 6 CCK theming
1. Register a theming function for a form in your themes template.php file
where content_type is the machine name of your content type
2. create a preprocess function
3. create a template file called content_type_node_form.tpl.php (the name is the same as the template value from step 1)
P.S. Don't forget to flush your theme registry to apply the changes.
Thanks!!
Thanks!!
module instead of template file.
or register the theme function in a module by placing the code in the module.
Thanks
Thanks man,
Is there any way to give paging for node reference filed ? drupal 6
svnindia