building button

Permalink
Hi,

I'm using Concrete5 since 3 years but i'm pretty sure i'm doing something wrong.

I need to be able to insert a Button Block which the code is like this and TITLE should be user changeable :
<ul class="actions">
<li><a href="#" class="button special big">Get in touch</a></li>
</ul>


For this i will create an AREA and then with Content Block i will have add a list and give them the special class.

But i wonder if there is a way to create a button block with possibilities to change only text ??

Thanks in advance

Chris

chrismodlao
 
chrismodlao replied on at Permalink Reply 1 Attachment
chrismodlao
Hi,

I did follow a tread :https://www.concrete5.org/community/forums/customizing_c5/content-bl...

To create this Block's Button, i did copy the content block from the concrete5 directory then i did paste in Block to the root of my installation. Then i modify those file :
- add.php
- controller.php
- db.xml
- view.php
I'm now able to create a button with custom link.
I can create a button now...

... but when i try to edit it again i got an error (see attached file)
It seems i have to change something in the edit.php but dont know what??

The code is exactly the same as the tread except i did have change the class of the link
(if my code needed let me know).
mnakalay replied on at Permalink Reply
mnakalay
Hello,
The thread you are referencing doesn't have any code for the edit screen so it's hard to check.

The error you are getting seems to indicate that your code is calling the function getContentEditMode() and can't find it.

Do you have anywhere in your code a call to that function? Maybe something like
$this->getContentEditMode()
chrismodlao replied on at Permalink Reply
chrismodlao
Thats my Edit.php

<?php
defined('C5_EXECUTE') or die("Access Denied.");
//$replaceOnUnload = 1;
$bt->inc('editor_init.php');
?>
<div style="text-align: center" id="ccm-editor-pane">
<textarea id="ccm-content-<?php echo $b->getBlockID()?>-<?php echo $a->getAreaID()?>" class="advancedEditor ccm-advanced-editor" name="content" style="width: 580px; height: 380px"><?php echo Loader::helper('text')->specialchars($controller->getContentEditMode())?></textarea>
</div>
mnakalay replied on at Permalink Reply
mnakalay
I see. What is happening is your add screen includes 2 simple text fields, one for caption and one for url.

Your edit form, on the other hand, is totally different, you are trying to load a WYSIWYG editor using specific functions that are not there in your block.

Try this: modify your add.php file to be like this:
<p>Enter button details.</p>
<?php
echo $form->label('btnCaption', 'Button Caption');
echo $form->text('btnCaption', $btnCaption, array('style' => 'width: 300px'));
echo $form->label('btnURL', 'URL');
echo $form->text('btnURL', $btnURL, array('style' => 'width: 300px;'));
?>

Then delete everything in your edit.php and replace it with
<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<?php 
$bt->inc('add.php', array('btnCaption' => $btnCaption, 'btnURL' => $btnURL)); 
?>
chrismodlao replied on at Permalink Reply 1 Attachment
chrismodlao
Hi,

I did try it and still error when editing.
This time another one.

Check attached file.

But you right something happen with the EDIT.php file.
mnakalay replied on at Permalink Best Answer Reply
mnakalay
in your add.php, just below
<?php

add
$form = Loader::helper('form');
chrismodlao replied on at Permalink Reply 1 Attachment
chrismodlao
Hi,

Thanks like this it works !!!
I did compile all files in this post. Check attached file.

Cheers
mnakalay replied on at Permalink Reply
mnakalay
Great!

Now if you're goal was just to build a simple button add-on (and not to learn how to do it), maybe you should consider using this free add-onhttps://www.concrete5.org/marketplace/addons/designer-content/...

You can use it to build any block you want
chrismodlao replied on at Permalink Reply
chrismodlao
I learned a lot already with this tread.

I will check your link out. Thanks.
RickJ replied on at Permalink Reply
mnakalay,

Wow ... thanks for the tip. Now if only I could add a simple counter to the file download feature ... ;)

[Edit]
Un Wow, seems to not be available for 5.7. Can you confirm one way or the other?
mnakalay replied on at Permalink Reply
mnakalay
If you mean designer content, an equivalent exists which has very high ratings but is not free.
you have 2 versions that complete each other, the second one offering more advanced field types:
http://www.concrete5.org/marketplace/addons/block-designer...
http://www.concrete5.org/marketplace/addons/block-designer-pro...