Custom backgrounds in main div
Permalink 1 user found helpful
I have a problem I can't figure out.
My site consists of different backgrounds in the main content area for each page.
How do I build this into an editable block?
Do I create a new page template for each page?
The text that the editor inputs will sit on top of a white box over the photograph.
Seehttp://new.iteams.org.nz/concrete5.4.1/...
My site consists of different backgrounds in the main content area for each page.
How do I build this into an editable block?
Do I create a new page template for each page?
The text that the editor inputs will sit on top of a white box over the photograph.
Seehttp://new.iteams.org.nz/concrete5.4.1/...
Hi,
You need to create a new page attribute as you want for instance lets use 'background'. To create the attribute visit the link -
http://www.concrete5.org/help/building_with_concrete5/developers/at...
and you can get the attribute (background image)
as
You need to create a new page attribute as you want for instance lets use 'background'. To create the attribute visit the link -
http://www.concrete5.org/help/building_with_concrete5/developers/at...
and you can get the attribute (background image)
as
Excuse my lack of knowledge here but...
my current code for the main content is:
<?php
$a = new Area('Main Content');
$a->display($c);
?>
what is the full code then?
And I aim the background:url to each new image?
my current code for the main content is:
<?php
$a = new Area('Main Content');
$a->display($c);
?>
what is the full code then?
And I aim the background:url to each new image?
I have made a directory in models/attributes/type/background but what file goes into this directory and what is the coding?
Hi,
Copy concrete/models/types/image_file/controller.php and paste it in models/types/background/controller.php, then change the class name ImageFileAttributeTypeController as BackgroundAttributeTypeController
and create a xml file having a table (atbackground) with two field
1. avID
2. fID
in models/types/background/db.xml
Try it, Good luck !!!
Copy concrete/models/types/image_file/controller.php and paste it in models/types/background/controller.php, then change the class name ImageFileAttributeTypeController as BackgroundAttributeTypeController
and create a xml file having a table (atbackground) with two field
1. avID
2. fID
in models/types/background/db.xml
Try it, Good luck !!!
do I need to create a new table in mysql first? Or do the 2 ids exist already?
what is the coding for the xml file?
what is the coding for the xml file?
<?xml version="1.0"?> <schema version="0.3"> <table name="atBackground"> <field name="avID" type="I" size="10"> <KEY></KEY> <DEFAULT value="0"></DEFAULT> <UNSIGNED></UNSIGNED> </field> <field name="fID" type="I" ></field> </table> </schema>
For more details visit
http://www.concrete5.org/documentation/how-tos/creating-and-working...
Create an image attribute with handle bkImg.
Then add that attribute to the page type so it shows up in the properties automatically (page types-> edit).
Then upload your background images to the file manager.
Then update your page type's code like this:
Now you can go page->edit page->properties->custom attributes and select the background image from the file manager.
I'm using the php shorthand if / else.
Make sense?
Then add that attribute to the page type so it shows up in the properties automatically (page types-> edit).
Then upload your background images to the file manager.
Then update your page type's code like this:
$bkg = $c->getAttribute('bkImg'); ?> <div id="content"<?=($bkg ? ' style="background-image: url(' . $bkg->getURL() . ')"' : '');?>> <?php $a=new Area('Main Content'); $a->display($c); ?> </div>
Now you can go page->edit page->properties->custom attributes and select the background image from the file manager.
I'm using the php shorthand if / else.
Make sense?
I usually use the collection (page) handle as an ID for the main DIV.
For example, If I use the code:
Which would gives me an ID for login, register, about-us, .. etc and easy way to customize this area or even the whole page.
For example, If I use the code:
<div id="<?=$c->getCollectionHandle()?>"> <!-- main page content --> </div>
Which would gives me an ID for login, register, about-us, .. etc and easy way to customize this area or even the whole page.
Much cleaner than my inline style!
Jon