Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
Hello KK,

Now I'm trying to use a pagebuilder function.

I thought it took a week to learn, but one day was enough.
It is a really good function.

I don't check codes yet, But I have an idea to try.

Can I use one block for several themes?
Because if I can, I don't loose content data to change another blocks.

Once I made some codes for this idea with couch basic functions.
But codes were some kind of messy and to register blocks were hard to maintenance.

If there is a easy way to control "_pb_template" from backend-screen,
it will be much useful.
Hi,

Could you please explain in more detail what you wish to have?
I am sorry but couldn't fully grasp the use-case from the original post.
Hello KK,

I'm sorry for my poor explanation. I will do my best with English.

/////
USECASE:

CTA(Call To Action) blocks have input data as followings.

<cms:editable name='title'>
<cms:editable name='subtitle'>
<cms:editable name='body'>
<cms:editable name='image'>


Then let's say there are three themes of CTA.

TypeA:
Line1: subtitle
Line2: title
Line3: body
Line4: image

TypeB:
Line1: title
Line2: subtitle
Line3: image + body

TypeC:
Line1: title + subtitle
Line2: body
Backgroud-image: image


/////
What I am thinking is ,

pb/cta/embed = definition of input-data
pb/cta/theme = definition of view(how they are displayed)

So one input-data can have different viewes.

This make blocks change their styles without re-input data
like changing their clothes.

Eespecially if blocks have repeatable-section, it makes me happy.


/////
Maybe I can put <cms:editable name='select_type'> in pb/cta/embed.
Then useing 'select_type' in pb/cta/theme with if statements to select type to display.


/////
KK, can you understand my poor explanation?
Hi @gem3,

Sorry for getting back this late.

I think the solution you yourself proposed should suffice for the use-case -
Maybe I can put <cms:editable name='select_type'> in pb/cta/embed.
Then useing 'select_type' in pb/cta/theme with if statements to select type to display.

Following which, suppose we have a mosaic defined as follows -
Code: Select all
<cms:mosaic name='blocks' label='Blocks' body_class='_pb'>
    <cms:tile name='ct01' label='CT01' _pb_template='cta/theme/CT01' _pb_height='350'>
        <cms:embed 'pb/cta/embed/CT01.html' />
    </cms:tile>
    ...

Then, for tile ct01, PageBuilder will fetch data from 'pb/cta/embed/CT01.html' and use 'pb/cta/theme/CT01.html' (as indicated by '_pb_template') to display it.

However, there is nothing to prevent 'pb/cta/theme/CT01.html' from embedding any other snippet within itself.
So if we put <cms:editable name='select_type'> in 'pb/cta/embed/CT01.html', the theme file 'pb/cta/theme/CT01.html' can use the selected value to load the appropriate snippet.

For example, we can place the additional snippets as follows
Code: Select all
snippets
    |_pb
        |_cta
            |_embed
                |_CTA01.html
            |_theme
                |_CTA01.html
                |_CTA01a.html
                |_CTA01b.html
                |_CTA01c.html

where the CTA01a.html, CTA01b.html etc. will have the various views and and the CT01.html can have only the following code -
Code: Select all
<cms:if select_type eq 'type_a'>
    <cms:embed 'pb/cta/theme/CT01a.html' />
<cms:else_if select_type eq 'type_b' />
    <cms:embed 'pb/cta/theme/CT01b.html' />
<cms:else_if select_type eq 'type_c' />
    <cms:embed 'pb/cta/theme/CT01c.html' />
</cms:if>

Hope this helps. Do let me know.
Hello KK,

Thank you for your reply.

The solution using "<cms:editable name='select_type'>" is simple and easy way for my case.

I already tried this way and it works.

My theme structure has only one html file.

Code: Select all
theme
                |_CTA01.html


Lazy way of one file.
Code: Select all
<cms:if block_type='1'>
    <!-- Call to Action 1 -->
    <section class="fdb-block">
    </section>

<cms:else_if block_type='2' />
    <!-- Call to Action 2 -->
    <section class="fdb-block">
    </section>

<cms:else_if block_type='22' />
    <!-- Call to Action 22 -->
    <section class="fdb-block">
    </section>

    <cms:else />
    Block Type Not Found!
</cms:if>
5 posts Page 1 of 1
cron