Author Topic: combine the content with the other files made from the template  (Read 1065 times)

Rienk

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
    • RTK NMD
Last week I started with compactcms and I must say i am very enthousiastic about it. Finally a cms which you can integrate within you own template not overloaded with a lot of modules and last but not least made under the GNU license. A job well done Xander. OK as newbie in this forum I have a question i ran into. The installation went flawless and soon I made my own template file integrated with the index.php from compactcms. I know this files is combined with the content file "home.php" in the content directory and by including this <? include_once($content); ?> in the index.php the content shows up.  Than I made different content files in the administration panel like eg. wie_is, waar_zit, wie_doet (dutch by the way). These files all show up in the content directory as supposed to be. All works well. But now the trick question. How does these different content files know in which files (files based on my own template) they can show up.

with kind regards.

Rienk Kuipers webdesigner.

With kind regards,

Rienk

Xander

  • Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 240
  • Karma: +5/-0
    • View Profile
    • CompactCMS.nl
Re: combine the content with the other files made from the template
« Reply #1 on: March 22, 2009, 07:34:02 PM »
Hi Rienk,

First of all thanks for the thumbs up :). CompactCMS has already become more extensive as I initially anticipated, but my main "target" still stands: one page to manage it all. And although I'd like to improve menu management and image management, I'm not going to break my one rule. And if I do: remind me of this message ;).

Having said that, onto your question:

If I've understood your question correctly you're wondering on how different content files (created by the administration) can be shown with your template applied to it, right? If so: you should realize that - and perhaps you've done so, but then you'll need to explain your question again - the index.php file is in fact the only file that is ever requested by your visitors. By including <? require_once('sitemap.php'); ?> to your index.php file, you include the script that manages these requests and includes (depending on the file name in the address bar) the right content file.

A simple example:

index.php

<? require_once('sitemap'); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo $title?></title>
...
</head>

<body>
   <h1><? echo $pagetitle?></h1>
   <h2><? echo $subheader?></h2>
   <? include_once($content); ?>
   ...
</body>
</html>


If you open up this file (mysite.com/) and no actual file is specified in the address bar (e.g.; waar_zit.html) the script will automatically include all details set in the administration for your home page. So in the code above <h1><? echo $pagetitle; ?></h1> becomes <h1>My homepage</h1>, the same goes for the <h2> tag and for the $content (= ./content/home.php) variable. If you do request a specific page (mysite.com/waar_zit.html) the script will include all details that are set for that page. Thus giving: <h1>Waar zit?</h1> <h2>Meer over onze locatie</h2> and for the $content variable: ./content/waar_zit.php.

So if you have included the <? include_once($content); ?> in your template file (index.php) and you request mysite.com/waar_zit.html, you should see the content showing up, that you have written in that particular file (content file in ./content directory).

I realize that I've now may written something you already knew and thus not answering your question :). But I guess it might be a good read for anyone not being completely sure about how it works. The technical question on how the script knows what file to include is a different one and might be defined as the "geheim van de smid" (the secret of the blacksmith). Please let me know if this helps you in some way or whether your were posting due to another matter!

Good luck!
Xander.
Don't ever hold back your suggestions. Help me either to improve CompactCMS or spread the word about it on sites such as Twitter, Digg, StumbleUpon, etc :). Thanks!

Rienk

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
    • RTK NMD
Re: combine the content with the other files made from the template
« Reply #2 on: March 23, 2009, 02:22:05 PM »
Again carefully reading your quick response I had to get a different approach in the way I usually think when I start a design project. Normally I make my own index.html file and the others files based on this index.html file included with css and javascript. And then link these files with internal links.

Now by using your great cms I have to let the cms making the html files based on the index.php incombination with the configuration of the .htaccess file. The confusion was that I missed the fysical html files but instead got a php file in the content directory. But now I begin to understand this method and I got the internal links to work properly. So thanks for your reply. BTW I'm not having the intention to know "the secret of the black Smit"  ;D This is for Your developers.

So in addition to this, the next problem: My project contains your cms index.php in combination with my designed look and feel. The only thing that needs to be changed in the template when I click on one of the items in this navigation menu is besides the content (which succeeded) is two pictures on the right side of the layout.

Looking through your tutorials about managing multiple templates I have done the next steps.:

1) First modified the index.php according the new layout and put this file in a subdirectory.
2) Modified the .htaccess according to your explanation by putting the subdirectory in the rewriterules.

I tested this and indeed the new template was visible in the browserwindow. Wow. This is really flexibel.
Unfortunetaly the only thing not changing is the content ($content) and the ($subheader) variables. I get some errors saying it cannot find the included file content home.php.
What is going wrong.?

Is it maybe an idea for the php developers also placing some variables like image placeholders in the template like ($image01) ($image02).

With kind regards.
Rienk
With kind regards,

Rienk

Xander

  • Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 240
  • Karma: +5/-0
    • View Profile
    • CompactCMS.nl
Re: combine the content with the other files made from the template
« Reply #3 on: March 24, 2009, 01:15:00 AM »
Quote from: Rienk
Again carefully reading your quick response I had to get a different approach in the way I usually think when I start a design project. Normally I make my own index.html file and the others files based on this index.html file included with css and javascript. And then link these files with internal links.

Great :)! So nothing has changed. You design your index(.php), but that is where it ends. This one file is the template of all your other files, making adjustments to the template much easier as before (even easier than e.g. Dreamweaver). Not mentioning the clean code it gives.

Quote from: Rienk
Now by using your great cms I have to let the cms making the html files based on the index.php incombination with the configuration of the .htaccess file. The confusion was that I missed the fysical html files but instead got a php file in the content directory. But now I begin to understand this method and I got the internal links to work properly. So thanks for your reply. BTW I'm not having the intention to know "the secret of the black Smit"  ;D This is for Your developers.

Good to read. I'm sure that now that you start to understand it fully, you won't want to use any other solution than a CMS in the future. Hopefully CompactCMS, but you never know.

Now onto your next problem. It sounds to me you might be making this more difficult than it actually should be. You write that with every page different images should show up depending on the page requested am I right? If so you could try to name images after the page name (+ a number) and make it once again dynamic.

Let me show you.

Let's pretend you have three pages. "Waar_zit", "wie_is" and "wie_doet". As you might have seen you can include <? echo $urlpage; ?> to show the current file name in the page (without the extension). So if you create six images and name them waar_zit1.jpg, waar_zit2.jpg, wie_is1.jpg, wie_is2.jpg, etc, you can dynamically insert these images, without changing anything to the default installation.

1) Place the six images in the /images/ directory
2) Put the following in the index.php where you want the images to appear:


<img src="./images/<? echo $urlpage; ?>1.jpg" alt="" />
<
img src="./images/<? echo $urlpage; ?>2.jpg" alt="" />


Now when you request mysite.com/waar_zit.html, the first line above will read <img src="./images/waar_zit1.jpg" alt="" />. Which I think is all you're after. Downside: you have to follow a strict naming convention for your images, but it is for sure the easiest way to get this done.

Let me know whether you've got this working & if it is actually what you were after.

Xander.


Don't ever hold back your suggestions. Help me either to improve CompactCMS or spread the word about it on sites such as Twitter, Digg, StumbleUpon, etc :). Thanks!

Rienk

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
    • RTK NMD
Re: combine the content with the other files made from the template
« Reply #4 on: March 25, 2009, 10:38:08 AM »
Hi Xander,

Your solution is exactly what I mean. I implemented your suggestion and it worked like a charm. Perfect. The last few years I tested a lot of cms. Even my own website is still made with Joomla. Joomla is driving in a Fiat Panda with a ferrari engine under the hood. Not even mentioning the unbelievable difficult implementation of self made templates.

Working with and testing your cms now for a little time I can say I love it. The main criteria were for me: easily configurable, easy to adapt in existing and self made templates and open source. This is exactly what your program is. Besides that your support is a really great bonus. I would like to contribute to your work, because php development at the moment is not my skill I think about writing additional tutorials or even videotutorials.

Greetz Rienk.

BTW googling for TinyMCE I came across the link to their Wiki documentation page. In this document you find a list http://wiki.moxiecode.com/index.php/TinyMCE:CMS_systems with CMS systems which are Tinyfied. I noticed that CompactCMS is not on the list. You have the ability to add your one to this list. This would be a opportunity to promote your program even more.
With kind regards,

Rienk

Xander

  • Developer
  • Administrator
  • Full Member
  • *****
  • Posts: 240
  • Karma: +5/-0
    • View Profile
    • CompactCMS.nl
Re: combine the content with the other files made from the template
« Reply #5 on: March 25, 2009, 01:10:20 PM »
Hi Rienk,

As cheesy as it may sound: messages like yours are all I'm after :). Maintaining a project like this one is a good experience and is a nice distraction from writing my current thesis for example. I only just released (couple of weeks ago) CompactCMS under the GPL license, so co-developing with others hasn't happened yet. And to be honest: I appreciate coding on this project by myself so I know exactly what is going on. So don't worry if you can't contribute in a PHP programming way ;)!

At the moment I've got some deadlines of the University I have to keep, but after the 3rd of April I really want to start developing a whole new website for CompactCMS. Don't want to make it any more complicated, but just add some structure and more documentation to make the script "laag drempelig" (easier accessible that is). An user made tutorial (or screencast) could be one of the things that help others to adopt CompactCMS too. Probably causing me to have more work, but hey... It's worth it :)!

If you ever want to contact me by e.g. e-mail, just check the source code of the script to look up my e-mail address, or add me to LinkedIn. I might by the way use your previous post as a testimonial one day (another feature I'm thinking of for the new website).

Good luck with your projects!
Xander.

P.s.: I've added CompactCMS to the list, thanks for the heads-up.
Don't ever hold back your suggestions. Help me either to improve CompactCMS or spread the word about it on sites such as Twitter, Digg, StumbleUpon, etc :). Thanks!