I want to present User fields from the profile2 module in drupal 7 in a custom template file.
I can edit profile2--bewerbungsprofil.tpl.php (where bewerbungsprofil is the name of the profile2 type) - but i want to edit the page.tpl.php-type output, so I have control over head and footer of the resulting html file.
Is there a special naming convention, like page--profile2--bewerbungsprofile.tpl.php, or is there some other way?
Try: page--profile-bewerbungsprofil.tpl.php
Here is a link to explain how template overrides are named
[[http://drupal.org/node/1089656]]
I think what you'd want to do is copy any tpl.php files into your local theme (sites/all/themes/yourtheme).
Related
I created my own user class according to:
https://docs.djangoproject.com/en/1.7/topics/auth/customizing/
Having this user created I would like to change description of the creation form. For now it's "First, enter a username and password. Then, you'll be able to edit more user options.".
Here's a screenshot:
I checked all meta fields and found how to change label of field but still can't figure out how to accomplish change of form description.
That's not in the form at all, it's just in a template:
https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/auth/user/add_form.html
Extension of Daniel answer:
The Django template engine has a defined order for loading templates. When it loads a template, it uses the first template that matches the name. You can override admin templates by using the same directory structure and file names.
You can add a custom admin template in the next steps:
Add template in the root of your project
Include the templates (settings.py)
Enjoy :)
I try to override an article category template with file newslist.php located in \templates\mediavolga\html\com_content\category\newslist.php
I set this file as alternative layout in category settings, but it does't works.
What I'am doing wrong, how to override default category blog template?
If you want to override the default category blog template, then it needs to have the same name as the default does. Try this:
1) copy all the files in components/com_content/views/category/tmpl/ into the folder \templates\mediavolga\html\com_content\category\
2) edit them and add an "echo 'this is my override blog.php'" to the files. If you see the output, then you can start modifying it.
I want to be able to use {% editable something %} inside of a layout template or a template that is included in various pages. For example a company slogan in the header or a text inside of page_menu.
I want to edit the value only on one place of administration (I don't want to have it duplicated over all pages models).
What is the best way to do this?
As commented above, the something arg can be any model instance - so all you'll need it a template tag or possibly context processor for getting the instance into every template, then voila.
I have a drupal English/French website.
I have a custom content type called 'ad' with all sort of fields.
I have created the file 'node--ad.tpl.php' in my theme directory
to customize the display of the 'ad' content.
I use pixture reloaded theme and DRUPAL 7.
I am trying to translate fields (both labels and values)
by using 'field translation' module.
Field translation works when I CREATE or MODIFY a content via admin.
However, when I DISPLAY a content of type 'ad', fields are not translated.
This is because drupal calls to 'node--ad.tpl.php' and the translation
module is probably not invoked.
When deleting 'node--ad.tpl.php', drupal calls the default node.tpl.php
with a similar results.
Any help would be appreciated,
Thanks in advanced,
Notes :
1 - I correctly activated every dependencies for the module.
2 - User interface translation correctly works.
OK
I found out myself how to do this.
I give the solution here.
It may help for others :
First, translate field labels and values in Configuration > Regional and language > Translate > Import. Do not import values as Fields but as User Interface. Do not specify
an URL (only msgstr and msgid).
Now, you need to add your t() function in the node.tpl.php for the translation to be effective. So :
In the node.tpl.php file, if you want to translate field label, write this :
$content['field_my_field']['#title'] = t($content['field_my_field']['#title']);
Then to translate field value do this :
$content['field_my_field']["#items"][0]['value'] = t($content['field_my_field']["#items"][0]['value']);
You can now render your field : print render($content['field_my_field']);
Is there a straightforward, common way to apply custom styling on admin change list element depending on its properties?
update
To be more precise: let's say I have a simple model object.
Foo
field1
field2
field3
#property
property1()
#property
property2()
ModelAdmin.list_display is defined as a subset of the available fields, so not every attribute (field/property) is displayed in the change list table.
I'd like to apply custom CSS class to the object's row when certain condition is fulfilled, for example: if foo_instance.property1 is True then add class bar to the corresponding tr element.
Now copy the template admin/base_site.html from within the default Django admin template directory (django/contrib/admin/templates) into an admin subdirectory of whichever directory you're using in TEMPLATE_DIRS. For example, if your TEMPLATE_DIRS includes "/home/my_username/mytemplates", as above, then copy django/contrib/admin/templates/admin/base_site.html to /home/my_username/mytemplates/admin/base_site.html. Don't forget that admin subdirectory.
Note that any of Django's default admin templates can be overridden. To override a template, just do the same thing you did with base_site.html -- copy it from the default directory into your custom directory, and make changes.
from django's tutorial
What exactly do you mean by "change list element" and "it's properties"? Using CSS 2 or CSS 3 selectors you can do some things. Otherwise, you might be able to do it easily using jQuery (or whatever). Since it is merely presentation related, I think this would be the cleanest solution.
Old question but if you stumble across it, the following tips might be helpful.
You can use django-liststyle to customise your admin changelist rows.
It's quite simple to implement your example:
class FooAdmin(admin.ModelAdmin, ListStyleAdminMixin):
...
def get_row_css(self, obj, index):
if obj.property1:
return 'bar'
return ''
Django Suit (not free) also offers "List row and cell attributes" style customisation