Remo Expand / Collapse - add input field

Permalink 2 users found helpful
The Expand / Collapse add-on has made my client very happy with its simple, clean functionality. However, they want to add a description below the title in the closed position.

What I have done. I have added a new field to the db.xml file (<field name="desc" type="X2"></field>); I have added an input text box to the form_init.php (<h3><?php echo t('Description')?></h3>

<input type="text" name="desc" value="<?php echo $controllerObj->desc?>" style="width:<?php echo ($textEditorWidth-40)?>px;"/> )

but I cannot figure out how/where/what to put in the view.php file make this work. I thought I could just add .$controller->desc. inside the div for the title - see below:

echo '<div id="ccm-remo-expand-title-'.$bID.'" class="ccm-remo-expand-title '.$className.'" data-expander-speed="' . $this->controller->getSpeed() . '">'.$controller->title. $controller->desc. '</div>';

Well, it isn't surprising that doesn't work. But I do want the description in the same div so that it will be in view when the content div is closed so it seems logical to put it here.

When I add/edit the block I can see my description field. Then when I add the description I want and save the block the description field doesn't show up.

I thought maybe the answer could help others too - in understanding how the three files connect and what's necessary to make it work.

Thanks in advance.

 
labdesignstudio replied on at Permalink Reply
Judging from the other posts in the forum and looking at the ones that get answered and the ones that don't I can see my question falls under the "don't" category.

However, anyone with knowledge on how to solve my problem could just point me in the right direction regarding the information I need to figure out the solution would be greatly appreciated.
adajad replied on at Permalink Best Answer Reply
adajad
Too bad you didn't get an answer as fast as you thought. Anyways, since you got my attention I had a go at it with your changes as a starting point. This is what I did:

First I downloaded the add-on so I could edit the files before installing the package.

In db.xml I added
<field name="description" type="X2"></field>

Notice me not using 'desc' as a name? That is just to not confuse the db (or me) since 'desc' is used for 'descending' in most cases.


In form_init.php right below the title input:
<h2><?php echo t('Description') ?></h2>
<input type="text" name="description" value="<?php echo $controllerObj->description?>" style="width:<?php echo ($textEditorWidth-40)?>px;"/>


In view.php I did the below. Bold title and line break after title added to separate title from description:
echo '<div id="ccm-remo-expand-title-'.$bID.'" class="ccm-remo-expand-title '.$className.'" data-expander-speed="' . $this->controller->getSpeed() . '"><b>' . $controller->title . "</b><br /> " . $controller->description .'</div>';


And now for the most important part, which you had missed. In controller.php (find the save function) you need to tell c5 to actually store the description in the database.
function save($data) {
    $content = $this->translateTo($data['content']);
    $args['content'] = $content;
    $args['state'] = $data['state'];
    $args['title'] = $data['title'];
    $args['speed'] = $data['speed'];
    $args['description'] = $data['description'];  //added description
    parent::save($args);
    $blockObject = $this->getBlockObject();
    if (is_object($blockObject)) {
        $blockObject->setCustomTemplate($data['layout']);
    }
}


Good luck!

Edit: had to edit some typos
labdesignstudio replied on at Permalink Reply
Thank you! thank you! thank you! I just learned a bunch. Much appreciated.
adajad replied on at Permalink Reply
adajad
Try it out and tell me if it works as expected. You can do all the changes without uninstalling the add-on. Once you have done all the changes, just go to '/dashboard/blocks/types/', click on 'Expand/Collapse' and then hit 'Refresh' to reload db.xml.

Edit: Also make sure you clear your site and browser cache after the edits.
labdesignstudio replied on at Permalink Reply
Thank you again.


It works as expected. A couple of things in trying to understand what I did
incorrectly or not at all - I had failed to mention in my post (actually I
had forgotten) that I had added the description to the save function in the
controller.php. The good news then, is that I am understanding the
structure of a block.

So why did your code work and mine didn't? Here's what I can see as being
different.
1. I used "desc" instead of "description" -
2. I did not consistently go to the dashboard to refresh my changes. It's
hard to believe that this would be what caused the problem since I didn't
change the db.xml file. Most of my stabbing around happened in the view.php
file.
3. I didn't have the <br> which separated the description from the title.

So which one do you think caused the problem?

labdesignstudio
adajad replied on at Permalink Reply
adajad
My guess is the use of desc instead of description. The rest is just
aesthetics. Caching might also have been your problem since it has different impact depending on the version of c5.
Den 28 feb 2013 22:45 skrev "concrete5 Community" <
discussions@concretecms.com>: