Background Image
Install and enable the modules
- Background Images 7.x-1.4: http://ftp.drupal.org/files/projects/bg_image-7.x-1.4.tar.gz
- Context 7.x-3.6: http://ftp.drupal.org/files/projects/context-7.x-3.6.tar.gz
- Backgroundfield 7.x-1.5: http://ftp.drupal.org/files/projects/backgroundfield-7.x-1.5.tar.gz
- Enable 'Context', 'Background Image', 'Background Image Context', 'Background Image UI', 'BackgroundField'
Configure 'Background Image' Module
- Enter D7 admin page: admin/structure/types/add, and create a new ContentType used for containing the images of background.
- view ContentType list and click 'manage fields' of 'background image'
- add an image filed which will be used to upload background images
- go to D7 admin page: admin/config/content/background-image
- select node type and node field as what we added at step 3
- Define the 'Selector' of CSS which by default is 'body', but we will probably change it to a specific class name whichever we want.
- Attach the css 'Selector' defined at the previous step to the html tags in any of the D7 template files you want.
Note: This is a global setting for 'Background Image' Module which will be used by 'Background Image UI' module. In 'Background Image UI' Module, we can choose different images for different pages. In order to make background image module effective, Background Image UI must be enabled and set properly.
Set up 'Background Image UI' Module
- Add two nodes of 'Background Image' ContentType and upload two different images
- switch to 'Background Images' tab and select a background image for different pages
- save and browse a content page, and search the class where I'm use 'div.background-image' in the source html code.
Note: 'Background Image' Module is good for setting a background image of the whole website or a group of web-pages. If you want to configure the background images of DIVs in the same web-page, it's better to use 'Background Field' Module.
Set up 'Background Field' Moudle
- Create a ContentType called 'background field' for test and add a new filed with a special type 'BackgroundField'
- Remember to set the CSS 'Selector' ('div.backgroundfiled' is used here) during the configuration steps of adding the new field
- Add a new content of 'Background Field' ContentType and search the CSS 'Selector' in the html source code
- You can use the CSS selector anywhere in this specific content page and it won't be found in the other content pages.
No comments:
Post a Comment