[opencms-dev] Trying to include a file and have template applied
M Butcher
mbutcher at grcomputing.net
Mon Nov 10 21:54:01 CET 2003
Here's a JSP I wrote to include an ad on a page. It allowed for two
scenarios -- either selecting a random ad from an ad directory, or
setting an ad specific to this content (via properties).
Actually, I have since reworked this JSP to make it significantly more
complex, but none of the changes made it much easier to understand, so
I'm including this old one.
Anyway, in this case, the ad could be either an image or a piece of
(plain) text. You should be able to switch it to use the contents of a
page document fairly easily.
The main JSP did a <cms:include> on this jsp to include it in the
rendered page. There is an example in the comments at the top of this JSP.
I used a combination of CSS, formatting in the main template, and
formatting coded into the JSP to achieve the look and feel that I wanted.
I hope that helps a bit.
Matt
M Butcher wrote:
> Polizzi, Jim wrote:
>
>> Wow!!!
>>
>> Thanks for taking so much time in answering my question...
>>
>> Actually - I was trying to simplify my question so that I could give
>> a good code sample. In reality - I'm to create it so that my users
>> (content editors) don't write ANY JSP's... but I left out some stuff
>> in my original description.
>>
>> Here's what I'm really trying to do (with NO code samples).
>>
>> I want to have an overall Page level template (Page.jsp template)
>> (which applies headers, footers, nav menus, etc.). Then, allow the
>> user to specify whatever body content that they like.
>>
>>
> This would be a regular template, right. I mean, this is what a
> template usually does.
>
>> Then, I'd also like my Page level template to look for (for example)
>> a file in the same directory as the current page called
>> "SideArea.html" (or whatever). If it finds it - it includes it -
>> otherwise, it doesn't.
>>
>>
> And again, this is pretty easy to do in the template. See if the file
> exists. If yes, then include it.
>
>> The SideArea.html file has a template defined for it (the
>> SideArea.jsp template) which has a table setup to make a nice
>> "feature box". The user enters their content into this SideArea.html
>> file - and I want the SideArea.jsp template applied to it.
>>
>>
> Now this is where I'm starting to get hazy. Why have a template
> defined for what equates to a snippet of code? Wouldn't you just put
> the "template" inside of the page template you spoke of above? I mean,
> if it's just a table, it would be better and faster to just use the
> main template to do the formatting.
>
> The exception to this would be if you wanted to do many different
> formats for the SideArea file (e.g. 6 or 7 different complex table
> layouts depending on what info is inside the SideArea.html file). In
> that case, you would have to basically create a recursive template
> parser/processor, as others have already suggested.
>
>> I can imagine several of these types of elements (SideArea / Feature
>> Area / etc.)... that will be included in the page if they exist...
>> the main point being that I want to provide Templates for each of
>> these Page Sub-Elements - to simplify the work that the User (content
>> editor) has to do to compose a rich page - that is consistant across
>> the site.
>>
>>
> I don't particularly see a problem with multiple additions. Your
> template may get bigger, but that is still preferable to implementing
> recursive template processing (for performance _and_ complexity reasons)
>
>> In order to do this - I need a way to include a file from my Main
>> Page Template (Page.jsp) - and the included file needs to have IT'S
>> template applied.
>>
>>
> Again, I think this solution is the more complex way of solving the
> problem.
>
> In the past, I've done the type of include that I'm explaining as a
> way of providing HTML ads, as well as dynamic or static content ("tip
> of the day" or extra bits of text). It works fairly well, and isn't
> hard to do.
>
> Others have done something slightly different: they have enabled the
> multiple content bodies option and used the extra body fields to add
> the additional text. For more on that, you may want to search through
> the list archives or check out the forums.
>
> Matt
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please
> visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ad_placement.jsp
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20031110/4341648a/attachment.ksh>
More information about the opencms-dev
mailing list