Modals

Custom Field as modal?

6 months 4 weeks ago #76274

Florian Bauer's Avatar Florian Bauer

Hello,
I created a editor custom field. Is it possible to render this custom field content as a modal popup, for instance using the content tag?

Or even better: create a layout override that renders the modal-plugin with the custom field as popup , so that the content author doesn't even see the shortcodes?


thank you

6 months 4 weeks ago #76282

Peter van Westen's Avatar Peter van Westen Admin

Yes, that is possible.
You can use the {modalcontent} tags around the custom field output.
See: www.regularlabs.com/extensions/modals/tutorial#inline-content

6 months 4 weeks ago #76290

Florian Bauer's Avatar Florian Bauer

I just have the problem that the modal-shortcodes don't get parsed if I just put them in the layout override. how can I use the shortcodes in the override?

6 months 4 weeks ago #76294

Peter van Westen's Avatar Peter van Westen Admin

It is probably due to the system plugin ordering. Try changing the ordering of the plugins in question.
See: www.regularlabs.com/blog/242-plugin-order-is-important

6 months 4 weeks ago #76298

Florian Bauer's Avatar Florian Bauer

ok, my solution was to put shortags including the field-output in a php-variable and echo everything. then it gets parsed...

6 months 4 weeks ago #76301

Peter van Westen's Avatar Peter van Westen Admin

Nice :)

6 months 4 weeks ago #76302

Florian Bauer's Avatar Florian Bauer

ah, forgot, before the echo I call $extras = JHtml::_('content.prepare', $extras);

it works. is there anything bad about it?

6 months 4 weeks ago #76304

Peter van Westen's Avatar Peter van Westen Admin

Calling the content plugins should generally not be necessary.
Result is that stuff gets called again and could cause pages to load a bit slower.

3 months 3 weeks ago #78332

Florian Bauer's Avatar Florian Bauer

Hello,
sorry, I noticed something strange, when I implemented this:

I created an editor custom field with my content for my modal popup, then created an alternative layout, that generates the code from the custom field to insert the modal-button. it looks like this:

<?php foreach ($this->item->jcfields as $field) : ?>
	<?php $extrascontent = $field->value; 
	    if($extrascontent):;
	?>
<div class="extras2">
      <?php $extras = '{modal html="'. $extrascontent .'" title="'.$this->item->title .' - Extras"}Extras{/modal}';
      echo $extras;
      ;?>
</div>
<?php 
   endif;
   endforeach; 
?>

you can see it here: www.oneworldfilmclubs.at/vergessene-opfer-die-gesamtreihe , the small button "extras in the upper right corner of the content should open the modal. It works, but it shows only the first paragraph of the editor custom field! Is has 2 more parapgraphs! Any idea why that is?

And also I set the width and height to 400px in the plugin options and the modal seems to shrink to that size, but then it moves even further and gets smaller. I don't know why.
*edit* I turned off the "autocorrect resize" and now the size is ok.

Would be great, if you could talk a look.

thank you

3 months 3 weeks ago #78337

Florian Bauer's Avatar Florian Bauer

I just printed the $extrascontent out and the content is there correctly! But when I look at the source code, there is a div with display: none, that shows only the first paragraph it is clearly not in the custom field-content, but this is what is used as the modal content.

I have no idea what's going on...

3 months 3 weeks ago #78340

Florian Bauer's Avatar Florian Bauer

OK, I found out, what was the problem!

The first paragraph contains a word wrapped in "", everything after that is not printed out in the modal!

3 months 3 weeks ago #78341

Peter van Westen's Avatar Peter van Westen Admin

Use the {modalcontent} tags for rich content like that.
Something like:

<?php
 $modal_id = 'field-modal-' . $field->id;
 echo '{modal content="' . $modal_id . '" title="'.$this->item->title .' - Extras"}Extras{/modal}';
 echo '{modalcontent ' . $modal_id . '}' . $extrascontent . '{/modalcontent};
;?>
See: www.regularlabs.com/extensions/modals/tutorial#inline-content

3 months 3 weeks ago #78343

Florian Bauer's Avatar Florian Bauer

perfect, thank you!