Jump to content

Planning my web template/engine


doctortim

Recommended Posts

Hi guys,

 

I have been building a website for my self that will store four main content types:

 

  • Blog
  • New Items
  • Hot List
  • Top Stories

 

I have built the index.php file as my web template; below the splash header it has a row of two content boxes/panels (a large one for the main content display, and a small one for the nav), then the second row has four evenly sized content boxes (to "advertise" each of my four content types).

 

Question 1:

 

In these four content boxes down the bottom I intend to (dynamically) show the latest 1 or 2 entries for that content type (in its respective panel), AND have a closed accordion at the bottom of each panel that opens up (and extends the panel) if the viewer would like to see a brief of the last five entries (rather than just one or two).

 

Should I put a table into the open state of the accordion, with my data echoed into the cells? Is there a better/easier way?

 

Question 2:

 

Is there a way to restrict an echo to a certain number of character? (that is I only want to display, say, the first 50 characters of an article as a preview, not an echo of the whole article (body of text)?

 

Question 3:

 

I'm a little unsure about how I direct people to my content from the home page. Say they choose something from the index.php (atm its index.html - obviously I will change that when I start adding PHP content) and I want their chosen content to appear in the main content box...

 

...do I need to create a php file for everwhere the user might go, every scenario they might click? just like with html?

 

Question 4:

 

Which brings me to my final (conceptual) question, how does php change the php content on a page without refreshing the html that remains the same??

 

 

I think you can all see the type of site I'm trying to build. If there is any important advice/rules etc people like to suggest for building such a dynamic site in the most efficient manner possible, then I'd love you to also comment on that.

 

 

Thanks. Sorry its a big question, but its all really about the same stuff.

 

 

 

Link to comment
Share on other sites

1/ This sounds more like a Javascript question.

 

2/ Yes, see substr().

 

3/ This is the entire basis of dynamic sites. Allot of sites can be programmed using one index.php file. You then pass arguments (via index.php?arg1=foo&arg2=bar) to this page which (through code) determins which data to pull for the request.

 

4/ It doesn't. Your entire page needs to be rebuilt (server side) on each request unless you plan on having parts of the content implimented using something like Ajax.

Link to comment
Share on other sites

OK combining 3 and 4 would I be right to say the following?

 

3/ that i can use the url query string (by my understanding is that which comes after /index.php?= ) to serve all of my content. Where would I learn the specifics of this? got a good source?

 

4/ when you move about on a dynamic site (or any site really) the images making up the interface are already cached and so that means subsequent pages after the homepage appear faster (eg. we don't think the interface is being re-drawn after we first arrive at the site)?

 

Also, with regard to 1/

 

Yes the accordion is done with the spry framework but what I'm asking is should I just echo my stuff into the open state of the accordion. Or is there a funky way to do it with php?

 

I think I'm just checking it will work with you, before I go and 1// Guess there is no reason why not.

Link to comment
Share on other sites

OK, I'm really not sure there is any specific resource with regard to using variables passed via the url, it quite a simple concept. A short example.

 

<?php

  if (isset($_GET['action'])) {
    switch ($_GET['action']) {
      case 'foo':
        echo "Do action foo";
        break;
      case 'bar':
        echo "Do action bar";
        break;
      case 'boo':
        echo "Do action boo";
        break;
      default:
        echo "Do default action";
        break;
    }
  } else {
    echo "No action passed";
  }

?>

 

Thats the absolute basics of it. Place that in a file then open it using http://localhost/file.php?action=foo etc etc.

 

I'm not sure what your question is in regard to 4 again. yes, images are cached, but your pages are still built again from scratch upon each request.

 

In regards to 1.

 

what I'm asking is should I just echo my stuff into the open state of the accordion. Or is there a funky way to do it with php?

 

PHP just outputs strings, all you need do is format those strings into html or whatever. There are no funky output functions in php.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.