My first experience on concrete5
Permalink 1 user found helpful
Hi everybody.
I'm starting the development of block in concrete5.
I'm not newbie with PHP but i found concrete5 a bit difficult. Maybe a question of usual.
This is a discussion opened for the possible questions that i'll can have.
My block is "a liking system", for easy the concrete5 learning. The owner of site chooses a button style for adding it to on a page. Simple.
Maybe a same block exists but it's not my goal to search a block. I want to familiarize me with Concrete5 and his fundamentals.
So, i'm searching for now : how to get the block id on the current page ? I've tried with "$page -> getBlocks()" but it gets all blocks of the page. Me, i want just the block id of my block of the current page. It's possible ?
Thanks a lot for your answers.
I'm starting the development of block in concrete5.
I'm not newbie with PHP but i found concrete5 a bit difficult. Maybe a question of usual.
This is a discussion opened for the possible questions that i'll can have.
My block is "a liking system", for easy the concrete5 learning. The owner of site chooses a button style for adding it to on a page. Simple.
Maybe a same block exists but it's not my goal to search a block. I want to familiarize me with Concrete5 and his fundamentals.
So, i'm searching for now : how to get the block id on the current page ? I've tried with "$page -> getBlocks()" but it gets all blocks of the page. Me, i want just the block id of my block of the current page. It's possible ?
Thanks a lot for your answers.
Yes, i'm trying to get the block id from the view.
So, i've tested your code like this in my controller :
But nothing, i have this fatal error : Call to a member function getBlockID() on a non-object.
Do you know what can i do ?
So, i've tested your code like this in my controller :
public function view() { print($b->getBlockID()); }
But nothing, i have this fatal error : Call to a member function getBlockID() on a non-object.
Do you know what can i do ?
Hey Taramis,
Sorry if I was unclear. I actually meant the view.php file, not the view() function in your controller. In the block controller you can access the block object with this code:
Hope that helps. Sorry for the confusion!
Sorry if I was unclear. I actually meant the view.php file, not the view() function in your controller. In the block controller you can access the block object with this code:
$block = $this->block;
Hope that helps. Sorry for the confusion!
Try:
$this->bID
Thanks a lot mhawke.
This code works great ! :)
$this->bID
This code works great ! :)
Bear in mind that if you use the c5 copy/paste, bID is not unique so may give problems if are using bID to create a unique identifier.
This howto by mkly includes more:
http://www.concrete5.org/documentation/how-tos/developers/obtain-a-...
This howto by mkly includes more:
http://www.concrete5.org/documentation/how-tos/developers/obtain-a-...
Good to know. I've been using bID for ages and have never seen any issues. What kinds of things should I be watching out for?
Should we all be embedding mkly's code in our controllers? Better, should the core provide a rock-solid variable (like bID) that we can use to isolate instances of blocks on a page?
Should we all be embedding mkly's code in our controllers? Better, should the core provide a rock-solid variable (like bID) that we can use to isolate instances of blocks on a page?
So I stuck mkly's code in the view() function of my controller and called the variable '$uniqueID' and then wrapped my block in:
which renders as:
[code]
<div id="BLOCK_1234">
.
.
.
</div>
{/code]
Cool!
<div id=<?php echo $uniqueID ;?>"> Existing block code . . . </div>
which renders as:
[code]
<div id="BLOCK_1234">
.
.
.
</div>
{/code]
Cool!
For many blocks, it just does not matter.
The main issue is where block code depends on a unique bID, such as tying javascript to a specific instance of a block, such as with sliders and galleries, where script attached to the block needs to know which gallery or slider to change. 2 blocks, same ID , and either you get a script collision and neither work, or one set of controls end up changing both pictures.
It can also give problems with duplicate css id's, illegal css, and consequently issues with jQuery selectors. Sometimes coupled to the previous issue. Or the 2nd block not getting any styling.
Before mkly's howto, I used to just add a big random number for such blocks.
The main issue is where block code depends on a unique bID, such as tying javascript to a specific instance of a block, such as with sliders and galleries, where script attached to the block needs to know which gallery or slider to change. 2 blocks, same ID , and either you get a script collision and neither work, or one set of controls end up changing both pictures.
It can also give problems with duplicate css id's, illegal css, and consequently issues with jQuery selectors. Sometimes coupled to the previous issue. Or the 2nd block not getting any styling.
Before mkly's howto, I used to just add a big random number for such blocks.
Good to know, thanks.
I guess I haven't built anything complicated enough to have conflicts, (or I've been lucky)
I guess I haven't built anything complicated enough to have conflicts, (or I've been lucky)
...or do that, haha. You're solution is much better. Thanks!
Thank you, bbeng89 but your solution wasn't worked.
So, i've tested the solution of mhawke and it works great. :)
So, i've tested the solution of mhawke and it works great. :)
Re-hi everybody.
I have another question. I want use and get images in my view.php.
Do you know where can i put my images and how can i get it in my view.php (or controller also, by a function for example) ?
Thanks a lot for your answer. ;)
I have another question. I want use and get images in my view.php.
Do you know where can i put my images and how can i get it in my view.php (or controller also, by a function for example) ?
Thanks a lot for your answer. ;)
Are you building this block from scratch? Because you really just need to use this:
http://www.concrete5.org/marketplace/addons/designer-content/...
It will show you how it's all done, including images.
http://www.concrete5.org/marketplace/addons/designer-content/...
It will show you how it's all done, including images.
Yes, i build my block from zero for learn well the rudiments of Concrete5.
So, sometimes i'm a bit lost. ^^
Thank you again for your answer. I'll look your link now. ;)
So, sometimes i'm a bit lost. ^^
Thank you again for your answer. I'll look your link now. ;)
The Designer Content add-on is one of the best things to help you learn as well as these two as well:
http://www.concrete5.org/marketplace/addons/c5-boilerplate/...
http://www.concrete5.org/marketplace/addons/custom-objects-demo/...
http://www.concrete5.org/marketplace/addons/c5-boilerplate/...
http://www.concrete5.org/marketplace/addons/custom-objects-demo/...
Hi mhwake,
If i want use images for my block, i need use the file manager. But, what i want, it's use my images like icons for my block, not images like photos, illustrations.
For example : if i build a custom menu block, i would like use some icons for my menu. Have i need really use the file manager for it ? It's a bit tedious, i think, to use it only for this.
I cannot use a folder (like "/blocks/myblock/images/") and use a path (relative or absolute ?) for do it ?
If i want use images for my block, i need use the file manager. But, what i want, it's use my images like icons for my block, not images like photos, illustrations.
For example : if i build a custom menu block, i would like use some icons for my menu. Have i need really use the file manager for it ? It's a bit tedious, i think, to use it only for this.
I cannot use a folder (like "/blocks/myblock/images/") and use a path (relative or absolute ?) for do it ?
Sure, just put these images in a sub-folder inside your block's folder and then use this to grab them:
<img src="<?php echo $this->getBlockPath();?>/images/yourimage.png">
Thanks a lot mhawke ! :)
This helps me a lot:
http://www.weblicating.com/doku/doku.php?id=cheatsheet#.UgYvKZJwqdw...
It doesn't have much about blocks but it has lots of other code examples.
Also, I learn a lot about what functions are available in concrete5 by just looking at the code. Most relevant block functions are in '[root]/concrete/core/libraries/block_view.php'
http://www.weblicating.com/doku/doku.php?id=cheatsheet#.UgYvKZJwqdw...
It doesn't have much about blocks but it has lots of other code examples.
Also, I learn a lot about what functions are available in concrete5 by just looking at the code. Most relevant block functions are in '[root]/concrete/core/libraries/block_view.php'
Hi everybody,
I have a question. I'm understanding the architecture of Concrete5 only now. Yes, it's very long. xD
So if i have understand well :
Collections
-|Page
--|Areas
---|Blocks
So, if i want to add a new area's type (handle). How can i do ?
For example, i want to add an area handle "Footer" in my C5 sites. How can i do it ?
Taramis.
I have a question. I'm understanding the architecture of Concrete5 only now. Yes, it's very long. xD
So if i have understand well :
Collections
-|Page
--|Areas
---|Blocks
So, if i want to add a new area's type (handle). How can i do ?
For example, i want to add an area handle "Footer" in my C5 sites. How can i do it ?
Taramis.
All you need to do is in your theme add a bit of PHP code like this:
Also, since its the footer and I assume it will likely be the same on every page, you might want to make it a global area:
<?php $a = new Area('Footer'); $a->display($c); ?>
Also, since its the footer and I assume it will likely be the same on every page, you might want to make it a global area:
<?php $a = new GlobalArea('Footer'); $a->display($c); ?>
WoW! Fantastic, no... magic! :)
I wasn't imagined that it works automatically with this way.
Thank's a lot!
I wasn't imagined that it works automatically with this way.
Thank's a lot!
Not a problem, glad I could help! Concrete5 does make it incredibly easy to convert HTML templates into themes.
Good luck!
Good luck!
Just to expand on bbeng89's answer... If you have an 'elements/footer.php' file in your theme folder, you might want to add your new area inside the 'footer.php' so it's added to the bottom of every page.
Also, I believe the 'official' way to display a Global Area is to leave out the $c in the brackets like this:
Putting the $c in a Global Area used to crash things but perhaps newer versions are more forgiving.
Also, I believe the 'official' way to display a Global Area is to leave out the $c in the brackets like this:
$a->display();
Putting the $c in a Global Area used to crash things but perhaps newer versions are more forgiving.
Yes, i proceeded like this.
Because in "header.php", i found some GlobalArea defined like this. So, i do it well, cool ^^
Thank you for complement, Mhawke :)
<?php $af = new GlobalArea('Footer'); $af->display(); ?>
Because in "header.php", i found some GlobalArea defined like this. So, i do it well, cool ^^
Thank you for complement, Mhawke :)
I use since recently the framework Bootstrap. Do you think that it will be easily to integrate Bootstrap in my theme ?
Taramis.
Taramis.
Yes, it is very easy to integrate with bootstrap. I've used bootstrap for most of my themes actually. You can do things like this (prior to bootstrap 3):
So you can see it makes it really easy create layouts for different page types.
<div class="row-fluid"> <div class="span4"> <?php $a = new Area('Sidebar Content'); $a->display($c); ?> </div> <div class="span8"> <?php $a = new Area('Main Content'); $a->display($c); ?> </div> </div>
So you can see it makes it really easy create layouts for different page types.
Super! It really like i've thinked. :)
Thx again.
Thx again.
Hi everybody,
I would like to ask you if possible to give me the links of your C5 website.
I want see some examples of C5 webdesign possibilities.
Taramis.
I would like to ask you if possible to give me the links of your C5 website.
I want see some examples of C5 webdesign possibilities.
Taramis.
Hi Taramis,
We use C5 for all our CMS sites. Here are few examples:
http://www.localfoodsurrey.com
http://www.4ti.com
http://www.bsaairriflebooks.co.uk...
http://www.holwoodfarm.co.uk
http://www.7starsleigh.co.uk
http://www.thekensingtonclinic.co.uk...
Hope this helps.
Regards
Simon
We use C5 for all our CMS sites. Here are few examples:
http://www.localfoodsurrey.com
http://www.4ti.com
http://www.bsaairriflebooks.co.uk...
http://www.holwoodfarm.co.uk
http://www.7starsleigh.co.uk
http://www.thekensingtonclinic.co.uk...
Hope this helps.
Regards
Simon
I'm very impressed with these folks:
http://linedesigngraphics.com/portfolio.html...
and concrete5 has it's own 'showcase' of sites here:
http://www.concrete5.org/about/showcase/...
http://linedesigngraphics.com/portfolio.html...
and concrete5 has it's own 'showcase' of sites here:
http://www.concrete5.org/about/showcase/...
Thanks simonknibbs and mhawke for your links.
At my evolution's stade, i have a bit bad to imagine that it's possible to make as of things with C5. I'm really amazed.
Moreover, the only thing it's that for make C5 sites like those examples, it will be more easily without C5 if the site isn't CMS but the goal is to make CMS so ...
I find that WP is more easy than C5. But in my new job, they use C5... so i need to understand and practice C5.
At my evolution's stade, i have a bit bad to imagine that it's possible to make as of things with C5. I'm really amazed.
Moreover, the only thing it's that for make C5 sites like those examples, it will be more easily without C5 if the site isn't CMS but the goal is to make CMS so ...
I find that WP is more easy than C5. But in my new job, they use C5... so i need to understand and practice C5.
I have a strange issue.
When i click on "Add a sub-page", just the edition page comes. I don't have the box for add a new sub-page.
Bug or not bug ? Do you know where can this come ?
Taramis.
EDIT: i have put two screenshot (2 attachments of this post)
First : a theme who works correctly with the adding of subpage
Second : my theme who doesn't work with the adding of subpage :(
When i click on "Add a sub-page", just the edition page comes. I don't have the box for add a new sub-page.
Bug or not bug ? Do you know where can this come ?
Taramis.
EDIT: i have put two screenshot (2 attachments of this post)
First : a theme who works correctly with the adding of subpage
Second : my theme who doesn't work with the adding of subpage :(
Hi everybody.
With my dashboard News extension, i've created an attribute for the single page "The news" but if we imagine that this site is made for a customer, he can attribute the attribute "News listing" at the others pages. I wouldn't like possible that he can do it.
So i have a question. How can i restrict a page attribute for one page only ?
With my dashboard News extension, i've created an attribute for the single page "The news" but if we imagine that this site is made for a customer, he can attribute the attribute "News listing" at the others pages. I wouldn't like possible that he can do it.
So i have a question. How can i restrict a page attribute for one page only ?
In concrete5 a page can contain many areas and an area can contain many blocks. So if you are on a page and know the area you want to retrieve your blocks from you can do
where $a is the area you want to retrieve the blocks from. This will return an array because it is possible for the area to contain multiple blocks, but if you know that you just want the first one you can access it by retrieving the first object in the array
You might also want to check out the documentation on working with block objects here:http://www.concrete5.org/documentation/developers/blocks/working-wi...