1

I'm new to Drupal Commerce.

I have created new product type and added custom fields everything and it's working fine.

I want to theme the Add a Product (form page). Please suggest me how to do that.

Thanks, Selva

2 Answers 2

2

It depends what part of the page you want to theme, simple CSS, change the layout, or adjust the form.

To add CSS, you could attach your CSS file in hook_page_build for that path.

To change the page template, you could override the page.tpl.php file as page--node--add--product.tpl.php

You could also set a custom template in hook_preprocess_page by checking for the relevant path and setting theme_hook_suggestions to your template (e.g node/add/product and node/[nid]/edit)

Another option is using hook_custom_theme to specify a whole new theme for that specific path.

Lastly, you can theme the form itself using hook_form_alter and using either a template for the form, or adjusting the form elements there.

2
  • 1
    Hi @DavidThomas, Thanks for your valuable comments. I have already achieved through hook_form_alter to adjusting the form elements and added CSS for them. But, I'm not sure how to use template for the form. Anyway I achieved my requirement. But, If you share how to use template for the form, it will help me in the future and some other people. Thanks, Selva Commented Jan 4, 2016 at 7:18
  • @david.thomas Why not use Display suite or panels?
    – Umair
    Commented Aug 30, 2018 at 8:11
1

If you are afraid of codes, download the module "themekey" and install . then download the theme you want to use for the path. After that, go to the themekey admin link to set the theme for the specific path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.