Adding new field to carousel items (slides)

Permalink Browser Info Environment
Regarding question about how to add a field to carousel items:
Every item(slide) at the owl carousel has some attributes that save at the database with json format. this means we have only one field (whaleOwlCarousel.items).
For adding a new attribute
1- You should add field into the \whale_owl_carousel\elements\dashboard\item_row.php

2- At the controller (\whale_owl_carousel\controllers\dashboard\files\whale_owl_carousel\controller.php), all item attributes first defined at the class header:
/*Items (slides): save in `items` with json format*/
public $itemImageID = 0;
public $itemHeader = '';
public $itemHeaderTypes = array();
public $itemHeaderType = 'h3'; //default value
public $itemDescription = '';
...

Here you can define a default value too.

3- There are a method name prepareFormValues at this controller that prepare form values before insert/update into db:
$this->itemsObj->{$i}->itemImageID = $_POST['itemImageID'][$key];
$this->itemsObj->{$i}->itemHeader = $_POST['itemHeader'][$key];
$this->itemsObj->{$i}->itemHeaderType = $_POST['itemHeaderType'][$key];
$this->itemsObj->{$i}->itemDescription = $_POST['itemDescription'][$key];
....

Then unset them:
unset($_POST['itemHeader']);
unset($_POST['itemHeaderType']);
unset($_POST['itemDescription']);
.....

And finally prepare item for tmp:
$this->itemsTmpObj->itemImageID = $this->itemImageID;
$this->itemsTmpObj->itemHeader = $this->itemHeader;
$this->itemsTmpObj->itemHeaderType = $this->itemHeaderType;
$this->itemsTmpObj->itemDescription = $this->itemDescription;
.....

Off course it may be a little confusing, but all you have to do is clone a attribute like itemDescription at these sections of code. Data will convert to json and save at the database.

Type: Discussion
Status: New
shahroq
View Replies:
BirgirGisla replied on at Permalink Reply
This is excellent guide.

I needed to add few extra text fields in order to display testimonials on my site using the Owl Carousel. With this you can easily create simple text carousel in addition to the images. Makes this add-on even better, which is fantastic in the first place.

Thank you shahroq.

Cheers,
Birgir

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.