Forums

Use Chronoforms/ChronoConnectivity like a CCK

galbur 02 Dec, 2015
Hi

Im not shure how to solve this:
For a Project i work with an Event-Component. I would like to have the ability to use chronoforms as the Main Form for registered users to upload their events.
For testing i used a simple form and a DB Save Action and i was able to write title, Date, etc. in the Event-Manager Table and i can see the then new entries in the list view. Quit perfect.
There are two fields in this table: "short_description" and "description".
I would like t have a predeifned layout for the "short_description" and the "description" field.
Is there a possiblity to have fields in the form and to put the values the right position of the short_description" and the "description" field? Many People are a little overhelmed with WYSWYG Editors.

Maybe this is something i can do with ChronoConnectivity and/or Chronoforms?

Thank you
Chris
GreyHead 02 Dec, 2015
Hi Chris,

Yes, you can do that. In the form On Submit event add a Custom Code action and use PHP+HTM to assemble the different inputs as you need them. Save the result to $form->data[short_description'] and $form->data['description']

The method is the same as in this FAQ

Bob
galbur 03 Dec, 2015
Hi Bob

Thank you very much. Just great! It works!
Only one Problem: Ist it possible to include Images this way? I tried to use an upload and the resize action.
But when i try to send the form a firefox prompt opens and wants to save something. Missconfiguration?

Cheers
Chris
GreyHead 03 Dec, 2015
Hi Chris,

You can certainly upload images and then add links into the content using <img . . /> tags.

What error do you get exactly?

Bob
galbur 04 Dec, 2015
Hi Bob

Thanks again. I made a mistake. The error was because i used a download instead of an upload action.😶
So now it seems to work. It saves the image in the new table. But only the filename and not the path.
And i'm not shure how to write the filename of the resized image in the table.

Cheers
Chris
GreyHead 04 Dec, 2015
Hi Chris,

There are two ways to do this:

+ if you always use the same folder to save the images then you can simply recreate the path or url as needed
<?php
$form->data['image_path'] = JPATH_SITE.'/some/folder/path/'.$form->data['file_name'];
$form->data['image_url'] = JURI::root().'some/folder/path/'.$form->data['file_name'];
?>


+ Or you can save the full URL and/or path to the table. If you temporarily add a Debugger action to your form you will be able to see that they are available after the resizer action and can be copied to the $form->data[''] array in the form that you need them to save.

Bob
galbur 04 Dec, 2015
Hi Bob

Great. One step further. Thank you.
So i was able to save the path of the uploaded image, but not the path of the resized image.
I used 'thumb_big' as the array. But something is wrong.

<?php
$form->data['short_description'] = "<p><strong>{$form->data['title']}</strong></p>
<p><img style='float:left; margin-right: 10px; width=200; height=auto;' alt='event-img' src='http://localhost/17_02_ifma/components/com_chronoforms5/chronoforms/uploads/11_test_formular_event_booking-03/{$form->data['thumb_big']}'/></p><p>{$form->data['subtitle']}</p><p>{$form->data['location']}<p><p>{$form->data['adress']}</p><p>{$form->data['short_description2']}</p>"
;?>


Cheers
Chris
GreyHead 04 Dec, 2015
Hi Chris,

What information do you see about the resized images in the Debugger? That should give the clue about addressing the thumb-nail.

Bob
galbur 04 Dec, 2015
Hi Bob

These ar the Debug Infos

Date Array
Array
(
    [bild] => Array
        (
            [name] => 20151204144913_sugar_skull.jpg
            [original_name] => sugar_skull.jpg
            [path] => M:\xamppserver\xampp_17_ifma\htdocs\17_02_ifma\components\com_chronoforms5\chronoforms\uploads\11_test_formular_event_booking-03a\20151204144913_sugar_skull.jpg
            [size] => 159879
            [link] => http://localhost/17_02_ifma/components/com_chronoforms5/chronoforms/uploads/11_test_formular_event_booking-03a/20151204144913_sugar_skull.jpg
            [thumb_big] => 20151204144913_sugar_skull_big.jpg
            [thumb_med] => 
            [thumb_small] => 
        )

)



And:
Debug-Info
Array
(
    [17] => Array
        (
            [Files Upload] => Array
                (
                    [0] => Upload routine started for file upload by : bild
                    [1] => M:\xamppserver\xampp_17_ifma\htdocs\17_02_ifma\components\com_chronoforms5\chronoforms\uploads\11_test_formular_event_booking-03a\20151204144913_sugar_skull.jpg has been uploaded successfully.
                )

        )

    [15] => Array
        (
            [Image Resize] => Array
                (
                    [0] => 20151204144913_sugar_skull_big.jpg
                    [1] => 
                    [2] => 
                )

        )

    [13] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `all_eb_events` (`title`, `event_date`, `registration_type`, `access`, `short_description`) values ('Test 21', '2015-12-11', '3', '1', '<p><strong>Test 21</strong></p>
<p><img style='float:left; margin-right: 10px;  width=200;height=auto;' alt='event-img' src='http://localhost/17_02_ifma/components/com_chronoforms5/chronoforms/uploads/11_test_formular_event_booking-03/'/></p><p>Test 21 Subtitle</p><p>Dort<p><p>Hier und dort un überall</p><p><p>Test</p></p>');
                        )

                )

        )

)


Cheers
Chris
GreyHead 04 Dec, 2015
Hi Chris,

It looks as though you need $form->files['bild']['path'] assuming that you need the path and not the link/url.

Bob
galbur 04 Dec, 2015
Hi Bob

Sorry for my bad php skills. But what does that mean? Where do i have to made chages in the Custom code?

Thank you
Chris
GreyHead 05 Dec, 2015
Hi Chris,

I assumed that you wanted to include it in your short_description code?

Bob
galbur 05 Dec, 2015
Hi Bob

Yes

this is my shortdescription code:

    <?php
    $form->data['short_description'] = "<p><strong>{$form->data['title']}</strong></p>
    <p><img style='float:left; margin-right: 10px; width=200; height=auto;' alt='event-img' src='http://localhost/17_02_ifma/components/com_chronoforms5/chronoforms/uploads/11_test_formular_event_booking-03/{$form->data['thumb_big']}'/></p><p>{$form->data['subtitle']}</p><p>{$form->data['location']}<p><p>{$form->data['adress']}</p><p>{$form->data['short_description2']}</p>"
    ;?>


Maybe i have to change something here: {$form->data['thumb_big']} ?
When i use {$form->data['bild']} it works with the uploaded image. But how to use the resized picture?

Thank you
Chris
GreyHead 05 Dec, 2015
Hi Chris,

"It looks as though you need $form->files['bild']['path'] assuming that you need the path and not the link/url."

Bob
galbur 07 Dec, 2015
Hi Bob

Maybe I'm too limited. :-(
I changed url into path.
I used
src='{$form->files['thumb_big']['path']}'
or
src=''/home/allerha1/public_html/temp/ifma2.allerhand.ch/images/veranstaltungen/extern{'$form->data['thumb_big']}'

in the custom code

but nothing worked.

with:

src='{$form->files['bild']['path']}'
it works
but not with
src='{$form->files['thumb_big']['path']}'

thank you
chris
GreyHead 07 Dec, 2015
Hi Chris,

There's no context for the snippets you posted so I can't see if they are correct except that there appear to be some mis-matched quotes. From your previous example, but with the link instead of the path
    <?php
$form->data['short_description'] = "
<p><strong>{$form->data['title']}</strong></p>
<p><img style='float:left; margin-right: 10px; width=200; height=auto;' alt='event-img' src='{$form->files['bild']['link']}' /></p>
<p>{$form->data['subtitle']}</p>
<p>{$form->data['location']}<p>
<p>{$form->data['adress']}</p><p>{$form->data['short_description2']}</p>";
?>

Bob
galbur 07 Dec, 2015
Thank you again Bob

It works, like before. (with ['bild']) But the how can i get

http://ifma2.allerhand.ch/images/veranstaltungen/extern/20151207143450_IMG_0091_big.PNG
insead of
http://ifma2.allerhand.ch/images/veranstaltungen/extern/20151207143450_IMG_0091.PNG ??

This url should be written in the table "short_description". The resized Image instead of the original Image.

There is this Array [thumb_big] but i don't now how to handle it.

Thank you very much
Chris

Array
(
    [option] => com_chronoforms5
    [chronoform] => 11_test_formular_event_booking-02x
    [event] => submit
    [title] => fds
    [untertitel] => fdsa
    [event_date] => 2015-12-08
    [event_end_date] => 2015-12-23
    [veranstaltungsort] => fdsa
    [adresse] => fdsa
    [short_description2] => 
    [description2] => 
    [registration_type] => 3
    [access] => 1
    [hidden63] => 
    [hidden64] => 
    [senden_01] => Senden
    [bild] => 20151207143450_IMG_0091.PNG
    [short_description] => 
<p><strong>fds</strong></p>
<p><img style='float:left; margin-right: 10px; width=200; height=auto;' alt='event-img' src='http://ifma2.allerhand.ch/images/veranstaltungen/extern/20151207143450_IMG_0091.PNG' /></p>
<p></p>
<p><p>
<p></p><p></p>
    [id] => 16
)

Array
(
    [bild] => Array
        (
            [name] => 20151207143450_IMG_0091.PNG
            [original_name] => IMG_0091.PNG
            [path] => /home/allerha1/public_html/temp/ifma2.allerhand.ch/images/veranstaltungen/extern/20151207143450_IMG_0091.PNG
            [size] => 597423
            [link] => http://ifma2.allerhand.ch/images/veranstaltungen/extern/20151207143450_IMG_0091.PNG
            [thumb_big] => 20151207143450_IMG_0091_big.PNG
            [thumb_med] => 
            [thumb_small] => 
        )

)


Array
(
    [bild] => Array
        (
            [name] => 20151207143324_IMG_0095.JPG
            [original_name] => IMG_0095.JPG
            [path] => /home/allerha1/public_html/temp/ifma2.allerhand.ch/images/veranstaltungen/extern/20151207143324_IMG_0095.JPG
            [size] => 154917
            [link] => http://ifma2.allerhand.ch/images/veranstaltungen/extern/20151207143324_IMG_0095.JPG
            [thumb_big] => 20151207143324_IMG_0095_big.JPG
            [thumb_med] => 
            [thumb_small] => 
        )

)


Debug Info:

Array
(
    [17] => Array
        (
            [Files Upload] => Array
                (
                    [0] => Upload routine started for file upload by : bild
                    [1] => /home/allerha1/public_html/temp/ifma2.allerhand.ch/images/veranstaltungen/extern/20151207143043_IMG_0093.PNG has been uploaded successfully.
                )

        )

    [15] => Array
        (
            [Image Resize] => Array
                (
                    [0] => 20151207143043_IMG_0093_big.PNG
                    [1] => 
                    [2] => 
                )

        )

    [13] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `all_eb_events` (`title`, `event_date`, `event_end_date`, `registration_type`, `access`, `short_description`) values ('runk', '2015-12-15', '2015-12-16', '3', '1', '
<p><strong>runk</strong></p>
<p><img style='float:left; margin-right: 10px; width=200; height=auto;' alt='event-img' src='http://ifma2.allerhand.ch/images/veranstaltungen/extern/20151207143043_IMG_0093.PNG' /></p>
<p></p>
<p><p>
<p></p><p></p>');
                        )

                )

        )

)
GreyHead 07 Dec, 2015
Hi Chris,

I think this will give you the URL for the big thumb
<?php
$form->data['thumb_big_link'] = JURI::root().'/images/veranstaltungen/extern/'.$form->data['bild']['thumb_big'];
?>
Then use $form->data['thumb_big_link'] in PHP or {thumb_big_link} in HTML.

Bob
galbur 08 Dec, 2015
Hi Bob

Thanks again.

Still doesn't work.
This is my custom-code:

<?php
$form->data['thumb_big_link'] = JURI::root().'/images/veranstaltungen/extern/'.$form->data['bild']['thumb_big'];
?>

<?php
$form->data['short_description'] = "<p><strong>{$form->data['title']}</strong></p>
<p><img style='float:left; margin-right: 10px;  width=200;height=auto;' alt='event-img' src='{$form->data['thumb_big_link']}'</p><p>{$form->data['veranstaltungsort']}<p><p>{$form->data['adresse']}</p><p>{$form->data['short_description2']}</p>"
;?>



And this is what i get


Array
(
    [17] => Array
        (
            [Files Upload] => Array
                (
                    [0] => Upload routine started for file upload by : bild
                    [1] => /home/allerha1/public_html/temp/ifma2.allerhand.ch/images/veranstaltungen/extern/20151208102523_IMG_0091.PNG has been uploaded successfully.
                )

        )

    [15] => Array
        (
            [Image Resize] => Array
                (
                    [0] => 20151208102523_IMG_0091_big.PNG
                    [1] => 
                    [2] => 
                )

        )

    [13] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `all_eb_events` (`title`, `event_date`, `event_end_date`, `registration_type`, `access`, `short_description`) values ('', '', '', '3', '1', '<p><strong></strong></p>
<p><img style='float:left; margin-right: 10px;  width=200;height=auto;' alt='event-img' src='http://ifma2.allerhand.ch//images/veranstaltungen/extern/2'</p><p><p><p></p><p></p>');
                        )

                )

        )

)
GreyHead 08 Dec, 2015
Hi Chris,

It looks as though the values don't exist in the $form->data array when you are doing the DB Save. Is the sequence of events correct?

Bob
galbur 08 Dec, 2015
Hi Bob

Maybe that's the error?
I'm not really shure about the right sequence.

Thank you
and all the best

Chris
GreyHead 08 Dec, 2015
Hi Chris,

That looks OK. Please post the whole of the Debugger output so I can see what is in the $form->data array.

Bob.
galbur 08 Dec, 2015
Hi Bob

Data Array

Array
(
    [option] => com_chronoforms5
    [chronoform] => 11_test_formular_event_booking
    [event] => submit
    [title] => title
    [untertitel] => subtitle
    [event_date] => 2015-12-09
    [event_end_date] => 2015-12-16
    [veranstaltungsort] => location
    [adresse] => adresse
    [short_description2] => <p>shortdescription</p>
    [description2] => longdescription
    [registration_type] => 3
    [access] => 1
    [hidden63] => 
    [hidden64] => 
    [senden_01] => Senden
    [bild] => 20151208125047_8048217477.jpg
    [thumb_big_link] => http://ifma2.allerhand.ch//images/veranstaltungen/extern/2
    [short_description] => <p><strong>title</strong></p>
<p><img style='float:left; margin-right: 10px;  width=200;height=auto;' alt='event-img' src='http://ifma2.allerhand.ch//images/veranstaltungen/extern/2'</p><p>location<p><p>adresse</p><p><p>shortdescription</p></p>
    [id] => 23
)

Array
(
    [bild] => Array
        (
            [name] => 20151208125047_8048217477.jpg
            [original_name] => 8048217477.jpg
            [path] => /home/allerha1/public_html/temp/ifma2.allerhand.ch/images/veranstaltungen/extern/20151208125047_8048217477.jpg
            [size] => 1183634
            [link] => http://ifma2.allerhand.ch/images/veranstaltungen/extern/20151208125047_8048217477.jpg
            [thumb_big] => 20151208125047_8048217477_big.jpg
            [thumb_med] => 
            [thumb_small] => 
        )

)

Errors

Array
(
)

Debug Info

Array
(
    [17] => Array
        (
            [Files Upload] => Array
                (
                    [0] => Upload routine started for file upload by : bild
                    [1] => /home/allerha1/public_html/temp/ifma2.allerhand.ch/images/veranstaltungen/extern/20151208125047_8048217477.jpg has been uploaded successfully.
                )

        )

    [15] => Array
        (
            [Image Resize] => Array
                (
                    [0] => 20151208125047_8048217477_big.jpg
                    [1] => 
                    [2] => 
                )

        )

    [13] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `all_eb_events` (`title`, `event_date`, `event_end_date`, `registration_type`, `access`, `short_description`) values ('title', '2015-12-09', '2015-12-16', '3', '1', '<p><strong>title</strong></p>
<p><img style='float:left; margin-right: 10px;  width=200;height=auto;' alt='event-img' src='http://ifma2.allerhand.ch//images/veranstaltungen/extern/2'</p><p>location<p><p>adresse</p><p><p>shortdescription</p></p>');
                        )

                )

        )

)

GreyHead 08 Dec, 2015
Hi Chris,

Than you - as you can see the thumb URL has a 2 at the end instead of the file name. Please try this replacing $form->data with $form->files as we had earlier.
<?php
$form->data['thumb_big_link'] = JURI::root().'/images/veranstaltungen/extern/'.$form->files['bild']['thumb_big'];
?>

Bob
galbur 08 Dec, 2015
Hi Bob

Finally ... it works!
Great, and thank you so much.
I just hat to delete the firs '/' here: JURI::root().'/images/

Best wishes
Chris
GreyHead 08 Dec, 2015
Hi Chris,

Great to hear that it's working.

Sorry about the / that one slipped by. It's an odd Joomla! 'feature' that if you want the the root path then JPATH_SITE gives it - but without the trailing / but for the URL JURI::root() gives it - but including that /

Bob
This topic is locked and no more replies can be posted.