cancel
Showing results for 
Search instead for 
Did you mean: 

Include html pages in an html page

techyguy
Champ in-the-making
Champ in-the-making
Hello All,

I have a single html page being displayed at 'http://hostSmiley Tongueort/site/page.html'

This page is being render by a simple template that  <@streamasset asset=asset/>.

I am wondering if I could somehow include external pages inside the page.html?

I have tried have a <@include > within the page.html but it gets rendered as written.

OR

Would I be able to render the html page and have a custom method that looks for certain tags and performs actions on the tags?


Any suggestions?
6 REPLIES 6

erikwinlof
Confirmed Champ
Confirmed Champ
Hi,

I'm not sure from where you have got those tags but they will not work in an Alfresco server.
If you want to add your own page to Alfresco Share, please take a look at the following pages to get started:

Intro & understanding
http://wiki.alfresco.com/wiki/Share_Custom_Pages

Faster development
http://blogs.alfresco.com/wp/ewinlof/2011/10/12/create-pages-in-alfresco-share-using-new-out-of-the-...

Making components
http://wiki.alfresco.com/wiki/Web_Scripts_Examples

Cheat sheets for pages & components
https://twitter.com/#!/erikwinlof/media/slideshow?url=pic.twitter.com%2FJyWfvpkW
https://twitter.com/#!/erikwinlof/media/slideshow?url=pic.twitter.com%2FFZbz2CVW

techyguy
Champ in-the-making
Champ in-the-making
Those tags work within the Share/QS directories.

Was hoping to avoid using templates everytime I wanted to use a common element.

Was hoping that a html page within the site/document library could instance some of the tags that template files use ( '<#include>')

erikwinlof
Confirmed Champ
Confirmed Champ
Hi again,

The features in the Alfresco Web Quick Start application that you mention (the stream asset directive etc) is not included Alfresco Share out of the box and there is no plan in doing so. I'm sure you will be able to configure it in, but it is not something that we know has been done before. If you want to try that I suggest you start taking a look at wcmqs-webapp-context.xml and also compare the surf-config.xml file in both apps but if I think it might be hard to get assistance if you run into trouble.

If you instead could write down exactly what you want to do I'm sure I will be able to give you an alternate solution in Share.

Cheers,

:: Erik

techyguy
Champ in-the-making
Champ in-the-making
Thank You Erik-
Very nice offer also - extremely appreciated.

What I want to be able to do is create 2 html pages inside the document library. 
One of the Html pages will somehow include the contents of the other. 
I'd like to be able to do this all through the document library and inline editor, with no reliance on editing templates for every include.


(Somewhat like PHP require)

Any suggestions would be great, thank you.

drozes
Champ in-the-making
Champ in-the-making
This might be more suited for the webscript forum.
I am a noob still to alfresco but I think this approach would work.

If you are using <@streamasset asset=asset/> I am assuming you are in the WQS.

If this is the case - you already have a reference to your asset.
You can get the contents with:

asset.getContentAsInputStream().getStream();

Now, this is as far as I have gotten.  But with the stream - if you can buffer the stream and get a string of contents, you could technically output the string while replace any instances of <#include>

drozes
Champ in-the-making
Champ in-the-making
Once your have your stream and if you're in the JS serverside, you can turn it into a string.

var byteArr = new Array();

for(i=0; i < contentSizeNum; i++){
   byteArr.push( String.fromCharCode(contents.read()) );
}

//Turn array into a string
fileContentStr = byteArr.join('');