Page 1 of 1

templates including an external file using PHP

Posted: Tue Mar 11, 2008 3:51 pm
by hj
OK, I read this thread here.... http://forum.cmsmadesimple.org/index.ph ... 382.0.html

I tried adding the UDT

Code: Select all

{extfile filename='dynamic.php'}
with the filename changed to 'header.html' which is what my file is called, but it wouldn't allow me to create the tag, saying invalid code.

My standard old static pages site were PHP pages which used a to call an html mastead full of navigation links - this made it easy to just update the navigation in one place for the whole site.

Can I ....... create a template which is a PHP page and, either using the existing php icnlude include OR with a new tag, pull my html masthead into the page?

I tried using the php include in the template, and it just spat out a load of smarty tag errors in the output. And CMSMS won't accept my UDT?  :(

Hugh

Re: templates including an external file using PHP

Posted: Tue Mar 11, 2008 7:17 pm
by hj
right, I think i got it....I went to the wiki and found something there about including php which seemed to work.

Only thing is, I still fail to understand what that thread was about, and particularly didn't understand these two entries:
I use a user-defined tag called extfiles whose content is one line :

include($params['filename']);

and is called like this :

{incfile filename='dynamic.php'}

Steve
and
Hi Steve,

nice solution too - will add this to wiki.

Quote from: tractorboy on 29 Aug 2007, 09:56
I use a user-defined tag called extfiles

...

and is called like this :

{incfile filename='dynamic.php'}

Think it must be

Code:

{extfile filename='dynamic.php'}
???

Re: templates including an external file using PHP

Posted: Tue Mar 11, 2008 7:23 pm
by calguy1000
My standard old static pages site were PHP pages which used a to call an html mastead full of navigation links - this made it easy to just update the navigation in one place for the whole site.
I don't think you really get the point.  That's what page templates, menu manager templates, and the {menu} tag do.  You shouldn't be including html for this purpose.  CMS makes managing your menus and making numerous pages with a similar layout simple.

If you have a chunk of html that you want to re-use on different pages, that's where 'global content blocks' are used.

You should only be including php files if you're going to include another application.

We call it a 'content management system' for a reason.

Re: templates including an external file using PHP

Posted: Tue Mar 11, 2008 7:48 pm
by hj
I don't think you really get the point.
:o

You've got a lovely way of putting things, calguy ;)

The point is that juggling templates, menu templates, stylesheets for both, UDTs, php code that is stripped down, etc. etc. IS NOT SIMPLE for a) people in transition from years of table-based layout programmes, and b) people who haven't got 10 years programming experience before they even built their first cms.

;D

Whether I should or shouldn't be including html for this purpose is besides the point - if it suits me I'll do it!  The real point is whether I can or cannot do it with CMSMS. Yes? CMSMS is a tool, not a way of life.

Your own poll showed you that over 60% of CMSMS users have either never built a cms site before or very few.  The mantras of tableless layout and css purity are all very well if you've been around the houses and know your stuff. But a heck of a lot of people have either never built a cms before or may be in transition (or still thinking about it) from table-based layout programmes.  And in such landscapes as that, nothing is 'simple'.....;)  We may not get the point, or even want to get it, straight away!

However, thanks for the tip about the global content blocks!

hj

Re: templates including an external file using PHP

Posted: Tue Mar 11, 2008 10:10 pm
by calguy1000
CMSMS is a tool, not a way of life.
Yes, and like any tool you are better off taking the TIME to learn how to use it properly.  It's kinda like doing auto body work....  If you use the right tools, in the right way, and take the time to learn the right way, in the end your work will go alot easier and faster than if you just grab any old hammer and start swinging wildly.

Re: templates including an external file using PHP

Posted: Tue Mar 11, 2008 10:58 pm
by hj
Yes, and like any tool you are better off taking the TIME to learn how to use it properly.
That's what I'm trying to do...and it ISN'T simple - unless you've been doing auto bodywork for 10 years  ;D

However, you still didn't answer the question ;) ........... regardless of whether I should or shouldn't do something a particular way, which is a kind of semantic/philosophic thing based on the latest fandangled ideas out of palm valley or wherever all the geeks hang out.... can I do it? At this point in my learning curve I'm not bothered about 'purity' and 'elegance', I maybe want something quick and dirty! I can refine the ways of doing it as I learn more.

I've spent the last two hours trying to unpick the relationship between the various templates and stylesheets in the default CMSMS site. And it's completely scrambled my brain! Pick of the bunch is a stylesheet called Navigation:simple_vertical, which can only be accessed through template associations and doesn't show up in the main stylesheet list; said stylesheet also seems to have had all its font styling separated out to somewhere else!! - where I haven't discovered yet. Simple!!...it's a nightmare!

I find the signature at the bottom of your posts most revealing - and rather at odds with most people's notion of simple, I think! To your credit you do qualify your idea of simple, but it's not the simple sold on the CMSMS home page!

regards
hj

Re: templates including an external file using PHP

Posted: Tue Mar 11, 2008 11:33 pm
by calguy1000
However, you still didn't answer the question ;) ........... regardless of whether I should or shouldn't do something a particular way, which is a kind of semantic/philosophic thing based on the latest fandangled ideas out of palm valley or wherever all the geeks hang out.... can I do it? At this point in my learning curve I'm not bothered about 'purity' and 'elegance', I maybe want something quick and dirty! I can refine the ways of doing it as I learn more.
Yes, you can do it.  and here are the step by step intructions that should work (though I haven't tested).

1) go to 'Extensions >> User Defined Tags'.... Create a new user defined tag and call it include_php
in the text area that is supplied add:  (user defined tags are just php snippets that are stored in the database)

Code: Select all

include(trim($params['file']));
Click Submit.

2) Then in your page template, or wherever you want to include a php file you insert

Code: Select all

{include_php file='somefile.php'}
I've spent the last two hours trying to unpick the relationship between the various templates and stylesheets in the default CMSMS site. And it's completely scrambled my brain! Pick of the bunch is a stylesheet called Navigation:simple_vertical, which can only be accessed through template associations and doesn't show up in the main stylesheet list; said stylesheet also seems to have had all its font styling separated out to somewhere else!! - where I haven't discovered yet. Simple!!...it's a nightmare!
In the various page templates, under "Layout >> Templates".  You will see a css icon on each row.  This will bring up a page that will show you the various stylesheets that are attached to that template.    When you edit the template you will see a tag {stylesheet}, this inserts the code to attach the stylesheets to the resulting html when a page that uses that 'page template' is displayed. 

CMS allows you to separate your stylesheets logically for re-use.  You can put all of the css for forms in one stylesheet, for general styles in another, for layout in a third, etc, etc.  and then you can mix and match which ones you use on your various 'page templates'... so that you don't have numerous large stylesheets with almost identical content.
I find the signature at the bottom of your posts most revealing - and rather at odds with most people's notion of simple, I think! To your credit you do qualify your idea of simple, but it's not the simple sold on the CMSMS home page!
Yes, at various developer meetings we've discussed the general way we advertise the product and who we market it towards.  We've decided that we are marketing towards web professionals who want a tool that allows them to simply create a small to medium sized website with limited dynamic functionality, but extreme flexibility, and to do it quickly and easily after they learn a few things.  My signature line reflects that.

I hope this information helps.

Re: templates including an external file using PHP

Posted: Wed Mar 12, 2008 12:22 am
by hj
Yes, the information is most useful.

thanks for the guidance on the include matter. I did, in the interim, make a UDT called include_masthead and just stripped out the bits for the code. OK, it's not dynamic because it's hard wired to a particular file, but it worked. I'm sure your version is more dynamic and automated. Thanks.

Yes, I understand the fundamentals of stlyesheets, I've even made a few simple ones, purely to style table items and so on. But I find this example over-elaborate. I'm sure if you're using templates and css all the time, it's a doddle. If you've been using an html generating programme like Dreamweaver or Freeway, it's not. You have to think completely differently and it's much harder to visualise the output. It takes time to understand the relationship and interdependence of css and templates. As I say, i just spent two hours and I'm no clearer. In fact I've got a headache. But I'll persevere!

Well, if that's the market you're gunning for, great! But believe me, and like me, there are a lot of people out there using html generators to make commercial web sites. They're not programmers, they're not coders. Yes, they may understand the rudiments of css and xml and so on, they may come from a graphic design background, especially in the small-medium size sector. Personally I would recommend paying some attention to these 'migrators' as they're more likely to be the 'market' you're after than the more knowledgeable amateur enthusiasts! Just my reading of things.

Many thanks for the concise instructions.

regards
hj

Re: templates including an external file using PHP

Posted: Thu Apr 03, 2008 5:02 am
by pixelita
You know, instead of getting offended at what CalGuy is trying to tell you, you put your blinders on and stubbornly refuse to see that the way he's telling you to do it is much simpler in the long run.  There are none so blind as those who will not see.

The help forums are here for a reason.  And no, there are no dumb questions, only the ones that weren't asked. 

Ignoring the way something was designed to work and stating that you'll do it any way you darn well please when someone is telling you how to manage repetitive snippets of text and code probably won't get you any further enthusiastic help.  And you'll definitely need it if you persist in your way of doing things. :-P

And as far as all those migrators you are talking about, anyone who is designing web sites for a living better learn HTML, CSS and a little PHP -- and Smarty if they are going to mess around with CMSMS.  It makes me sick how many people are out there with absolutely no clue about HTML and CSS calling themselves web designers.  And getting away with it. 

Just my reading of things.  ;-)


Re: templates including an external file using PHP

Posted: Thu Apr 03, 2008 5:40 pm
by hj
eh?......who said I was offended at what calguy says? calguy says some very worthy and considered things, he's been extremely patient and helpful, I'm not offended at all. He's a cool guy who can keep his head when all around are losing theirs (unlike some people...)

What's eating your goat, mate? Too many shit sandwiches?

I could rip your rant apart but this is neither the time nor place for it.

All I would say is that if you must weigh in on a 'discussion' several weeks after the event, do try and keep it on track!

Have a nice day  :D


D I S C U S S I O N ......... not .......;)