Embed Content like PHP Include


#1

What would be Matrix's equivalent to using PHP include to embed content from one asset into another?


For example, I have created a asset listing which I was hoping to embed on a home page within a specific area of my code. The said home page has a container with raw HTML content. I was optimistically hoping to use some Keyword Replacement to achieve this, but not joy in my searches.



Any help greatly appreciated.


(Duncan Robertson) #2

It’s called Nested Content. Have a read of this:


http://manuals.matrix.squizsuite.net/content-types/chapters/nest-content/


#3

Thanks for the response Duncan. I looked into nested content, but doesn't this require a new content block? I'm hoping to nest the content into a specific area within my existing code.


(Nic Hubbard) #4

[quote]
Thanks for the response Duncan. I looked into nested content, but doesn't this require a new content block? I'm hoping to nest the content into a specific area within my existing code.

[/quote]



Yes, that requires a new content div. But, just create two RAW HTML content divs on either side of the nested content. Then put your code on either side.



– RAW HTML

– Nested Content

– RAW HTML


#5

[quote]
Yes, that requires a new content div. But, just create two RAW HTML content divs on either side of the nested content. Then put your code on either side.



– RAW HTML

– Nested Content

– RAW HTML

[/quote]



Ahh that sounds like an easy solution, Thanks both for your assistance.


(Dan Simmons) #6

Worth noting that in the latest version you can now also use the keyword %globals_asset_contents:X%, where X is the asset ID of the content you want to nest.


However, generally I'd recommend using nest content areas where possible as it will create a NOTICE link (where as the keyword won't).


(Nic Hubbard) #7

[quote]
However, generally I'd recommend using nest content areas where possible as it will create a NOTICE link (where as the keyword won't).

[/quote]



That is a great warning. I hope that is posted on the Manuals page.


(Bbuchel) #8

[quote]
Worth noting that in the latest version you can now also use the keyword %globals_asset_contents:X%, where X is the asset ID of the content you want to nest.



However, generally I'd recommend using nest content areas where possible as it will create a NOTICE link (where as the keyword won't).

[/quote]



Is there by any chance a way to reference source without the asset id?

We have imported a site of a few thousand pages in Matrix, they used a lot of SSI includes. Going through them one-by-one and changing is tiresome. Keen to do a find/replace with a solution.


(Nic Hubbard) #9

[quote]
Is there by any chance a way to reference source without the asset id?

We have imported a site of a few thousand pages in Matrix, they used a lot of SSI includes. Going through them one-by-one and changing is tiresome. Keen to do a find/replace with a solution.

[/quote]



Have you looked at the Matrix find and replace tool?