This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
hi everybody, i create simple gallery plugin and i want display two, three,four... gallery on one page, but display only first gallery. I find this https://octobercms.com/docs/plugin/components#unique-identifier, but i did not undrestand how it use on component. Somedody can help me?
I've actually got a new paid plugin coming out soon that should handle your use case easily. Let me know if you're interested in trying it out when it's released.
First thing you need to do is make sure each component is included on the page under a different alias: https://octobercms.com/docs/cms/components#aliases. Next, don't have your component include instance-specific data as page variables in the form of $this->page['variable']
. That sort of usage should only be used by components that there would only ever be one instance of per page. Instead what you should do is store your component data within public properties on the component class itself, and then access it via the __SELF__
accessor.
I.e. on your component class have something like this:
public $gallery;
public function onRun()
{
$this->gallery = GalleryModel::find($this->property('selectedGalleryId'));
}
and then in your default.htm partial have something like this:
{% for item in __SELF__.gallery.items %}
{% partial 'item' item=item %}
{% endfor %}
Thank y LukeTowers, i defeat problem. On cms page i forgot put on twig tag component) On component i succsessfully get data from model
1-3 of 3