Hello drupalers,
Sure hope you guys can help me with this one. I'm kind of a beginner in theming, but I've successfully solved the problems I've encountered so far...
I created a custom theme for a specific content type, because I wanted to get rid of the standard theme header regions and place the CCK fields to my likings. So ive created a page-node-mycontenttype.tpl.php and display the fields like: print $node->field_myfield[0]['view']
So my common logic sensed that there would be no need for the print $content; (thought it only prints the entire list of fields for that content type). But now i can't edit the form in any way (doesn't get displayed). And with the $content the fields get displayed twice.
So my question: How do i get my edit content form displayed without having to use $content. Must be overlooking something here. I've searched everywhere for a solution. Can't be that hard right?
Thanks,
Dave
Comments
Using wrong template
If I'm not mistaken you are suing the wrong template. page-node-mycontenttype.tpl.php is a template for the entire page. The template you should be using is node-mycontenttype.tpl.php. Move your code to a file named like that and you should be ok. More information here --> Drupal 6 Template Suggestions
Using the wrong template
If i use node-mycontenttype.tpl.php ill have all the headers and other stuff i don't want for this content type. It's a popup with an audio player and some custom fields in it..
A little confused
Reading back through your OP I'm a little confused. Is it that the node add/edit form is no longer displayed when you implement your custom node page without the $content variable being displayed? If this is the case then you will need to add logic to only display your fields when the node is being viewed and not on an add/edit page.
Now your confusing me
But we are on to something here... but ive had it for today, thanks for your input
It's simpler than I first explained
You need 2 templates. Read the page I linked previously. In D6 the order in which template suggestions are processed is the problem. You define a page template override for your node type but this also overrides the edit page. So just make another template for the edit page that is the same as the original and your done. You need both these:
page-node-mycontenttype.tpl.php
page-node-mycontenttype-edit.tpl.php
_
In your template.php file, you probably have code like:
You can add
&& arg(2) != 'edit'to the if statement, like so:Thats the stuff im looking for
Awesome! i'll try it out. Will let you guys know if it all works out. Thanks allot anyways!
No luck so far
Have been trying it out today... Carolyn's solution seems to be for drupal 5? Or am I mistaken?
Anyways I'm using this in my template.php:
Seems to work well, but its still overriding the Edit page. Adding page-node-stations-edit.tpl.php isn't working either. Is there a way to point the Edit/Add argument to the default page.tpl.php? Btw I'm using drupal 6 and the acquia_slate theme.
_
The code above works for me in d6. Have you tried adding
&& arg(2) != 'edit'to your code? for example:This docs page may be helpful: Setting up variables for use in a template (preprocess and process functions)
Thanks allot! it works
Worked like a charm!...
Thanks for the help!
Carolyn, I was struggling
Carolyn, I was struggling with the EXACT same situation the OP was going through and your solution not only fixed my problem, but it helped me sleep soundly at night!
;.)
You rock sista! Thanks again for the fix!
And Now The same for Drupal 7 :P
Okay so i've upadated to D7. Like i've been expecting: the code ain't working... Drupal 7 is pretty fun so far. It's just a puzzle to get it work in the same way.
Got it
Found the solution! Quite odd that page__node__nodetype has to be displayed with underscores instead of hyphens, as the template file is written as page--node--nodetype.tpl.php.
Now it works on D7. Hope this helps anyone out there.
Cheers!
Worked like a charm
Thanks makeapage for the Drupal 7 update. It worked for me.
----------------
Customer Support Engineer, Granicus
https://granicus.com
I also added delete
Carolyn,
The information you shared was very helpful for me, too. I created a content type and it was associated with a page template - and I couldn't edit the content type. So I followed your instructions and it worked perfectly. I also wanted the user to be able to delete the content via the edit screen, so I added && arg(2) != 'delete' and it worked, too. I hope that was the correct method (I am not a php coder, but understand the basics). Wanted to post this information in case anyone else wanted to add the delete option.
Tom Hale
New Day Web Design
www.newdaywebdesign.com