cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to use one plugin's block in another plugin?

SOLVED

Is it possible to use one plugin's block in another plugin?

Hi All,

 

Iam developing a project in M 2.3.5. I have 2 external extensions say ex-A and ex-B. I want to use a block of code of ex-A into ex-B (preferably a button with functionality). How can I call or use it.

 

I tried below code in ex-B and added template file too, but didn't work,

<referenceContainer name="content">
            <block class="class-of-ex-A"
                   name="sl-login-button"
                   before="-"
                   template="template-file-of ex-A"/>
        </referenceContainer>

 

Please suggest!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Is it possible to use one plugin's block in another plugin?

Hi @rekharajas68ab ,

 

Can you try below way 

1. Create the plugin b xml in custom theme. 

Example if xml in which you are editing is exampleB_index_index.xml

Create the same in custom theme and add below code

<body>
        <referenceBlock name="exampleb-block-name">
            !-- add block example A code here --!
        </referenceBlock>
    </body>

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

View solution in original post

4 REPLIES 4

Re: Is it possible to use one plugin's block in another plugin?

Hi @rekharajas68ab,

 

try to add only below code in ex-B

 

 Example: 

<block class = “class of ex-B->

<block class="class-of-ex-A"
                   name="sl-login-button"
                   before="-"
                   template="template-file-of ex-A"/>

</block>
 Flush cache and check the changes. 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

Re: Is it possible to use one plugin's block in another plugin?

Thanks!

 

Will try the same.

Re: Is it possible to use one plugin's block in another plugin?

@Nishu Jindal  adding block didnt worked for me..is there any other way to get it?

Re: Is it possible to use one plugin's block in another plugin?

Hi @rekharajas68ab ,

 

Can you try below way 

1. Create the plugin b xml in custom theme. 

Example if xml in which you are editing is exampleB_index_index.xml

Create the same in custom theme and add below code

<body>
        <referenceBlock name="exampleb-block-name">
            !-- add block example A code here --!
        </referenceBlock>
    </body>

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!