This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

jamesfawcett
jamesfawcett

Firstly let me just say what a fantastic CMS this is, an absolute pleasure to work with. I just have a question about the best way to go about something.

A layout I have coded up uses Mohsin's Magnific Gallery component which is working perfectly. I have created 22 different static pages which use the layout. I want to be able to pass in a variable to the component depending on which of the static pages you are editing, so that a different gallery is shown.

This is how the gallery is created in the layout:

[magnific pageGallery]
idGallery = 2
height = 190
width = 200

I want to be able to pass a different value to idGallery from within a static page. Is it possible, or am I using the CMS incorrectly? Should I be creating a separate layout or every page that needs a different gallery?

This is all very alien to me, I know Wordpress, Joomla and could hard code this so easily, but i'm determined to master OctoberCMS I see that it has so much potential!

jamesfawcett
jamesfawcett

To answer my own question here and to help others, I solved this by:

1) Create a partial containing the gallery. Link to the partial inside your layout:

{% partial "two-column-gallery" gallery= gallery %}

2) Inside the partial, include the component, and pull through the ID of the gallery:

[magnific pageGallery]
idGallery = {{ gallery }}
height = 190
width = 200
==
{% component "pageGallery" %}

3) On each seperate page that you create in the pages part of the admin, state the gallery that you want to feature on that page:

[viewBag]
title = "Industrial Signs"
url = "/our-signs/business-signs/industrial-signs"
layout = "two-column"
is_hidden = 0
navigation_hidden = 0
gallery = 7 

Hope this helps someone else, there may be a more efficient way of doing this but this was the only way i could find.

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.