Recent posts on static html pages problem?

Discussion in 'HTML & Website Design' started by TeDWooD, Jul 6, 2010.

  1. #1
    I have a section on my site in every page that has 'recent posts' and have just realised that i may have to update my static html pages to change the recent posts as with blogger or word press it changes automatically.
    Is there anyway i can add code so that it updates automatically?
     
    TeDWooD, Jul 6, 2010 IP
  2. bvraghav

    bvraghav Member

    Messages:
    123
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #2
    of course there is :)

    you will have to learn some php-mysql for that purpose...

    i would recommend, you can switch over to wordpress, it would be more efficient, from the production point of view...
     
    bvraghav, Jul 6, 2010 IP
  3. lqyromeo

    lqyromeo Peon

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    As the above post, because of your static pages, the page must be not update automatically.
    You could add the dynamic program of message board.
     
    lqyromeo, Jul 6, 2010 IP
  4. jamuasi

    jamuasi Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    if you use auto-update, it will be not static page any more.
    php-mysql can that auto-update. why not using wordpress script there? or get on coder to code for you a custom script.
     
    jamuasi, Jul 6, 2010 IP
  5. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #5
    I'm not sure if you're using a specific script, but it sounds like you're using plain static HTML. There's no way for it to "automatically update" because it is static. You either use a php script or you build your own and include it on your static page. :)
     
    Rainulf, Jul 6, 2010 IP
  6. zhoom

    zhoom Peon

    Messages:
    388
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I agree that you should go to a cms like wordpress. But....

    You could use a simple php include (server side include) so that you only have to update one php file every time you want to update all the 'recent posts' sections on every page. Your server will need to support php of course...

    Here is a tutorial I found on google. Although it is for a menu, you could use the same principle, just put your recent posts code into the php file that the tutorial names menu.php: http://www.tizag.com/phpT/include.php

    There are tonnes more tutorials avaiable if you google "simple php include tutorial"
     
    zhoom, Jul 7, 2010 IP
  7. TeDWooD

    TeDWooD Member

    Messages:
    135
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #7
    Thanks very much for the tutorial i am inexperienced with php but will give it my best shot :)
     
    TeDWooD, Jul 8, 2010 IP
  8. TeDWooD

    TeDWooD Member

    Messages:
    135
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #8
    Ok i have just done this tutorial. Does this mean that i will have to change all my file names to .php instead of html. Plus add the code into every one of my pages?
     
    TeDWooD, Jul 10, 2010 IP
  9. zhoom

    zhoom Peon

    Messages:
    388
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Yes. You will need to add the php include line of code to every page and save each as their own php file. Now when you want to edit your recent posts, you just amend the included php file and it will automatically update in every page you have included it in.

    But I should have mentioned before, your host will need to support php...Most do these days so hopefully your alright! :)
     
    zhoom, Jul 10, 2010 IP
  10. TeDWooD

    TeDWooD Member

    Messages:
    135
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #10
    Yea im with hostgator so shouldn't be a problem.
    A problem i have found though is how do i make it correspond with my css because on the tutorial its horizontal and my 'recent posts' are vertical.
     
    TeDWooD, Jul 10, 2010 IP
  11. zhoom

    zhoom Peon

    Messages:
    388
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Can you post the code of the php file you are including? And a link to your website? That would help alot....

    But generally, if you want your recent posts to list vertically, you should list them in an unordered list.

    Put a div wrapper around the unordered list and use css to style it so it displays how you want.
     
    zhoom, Jul 10, 2010 IP
  12. TeDWooD

    TeDWooD Member

    Messages:
    135
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #12
    http://www.modernrunner.co.uk/
    Okay there is the site. As you can see on the left hand side there is 'recent blog posts'. There is text below each module so i won't be able to simply name it. I have tried using the menu.php as this :
    <ul>
    <li>
    <h4><a href="runners-goals.html">Runners: What are your goals?</a></h4>
    <p>People all have their reasons for running but not many of them have goals of what they want to achieve...</p>
    </li>
    <li>
    <h4><a href="psychological-benefits-exercise.html">Psychological Benefits of Exercise</a></h4>
    <p>Psychological benefits of exercise are always a large talking point when people are asked why they start running...</p>
    </li>
    <li>
    <h4><a href="10-effective-avoid-injury.html">10 Effective Ways To Avoid Injury</a></h4>
    <p>Injury can be a pain, especially when it’s running injury. Here are 10 effective ways to avoid injury which can be started on your next run...</p>
    </li>
    </ul>
    which obviously doesn't work.
    As for the php include will i delete my actual side bar posts and put
    "<?php include("menu.php"); ?>
    </body>
    </html>"
    ?
     
    TeDWooD, Jul 11, 2010 IP
  13. zhoom

    zhoom Peon

    Messages:
    388
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #13
    So currently you have a div class content. You need to put the <?php include("menu.php"); ?> inside that div. That is all you should need to do. As long as your css applies to the content div, the formatting should stay the same as you have currently.

    You will also need to name the pages that you are including the php inside "filename".php, rather than .html

    You said "which obviously doesn't work". Do you mean the include is not working at all? Or the list is not formatted how you want it?
     
    zhoom, Jul 11, 2010 IP
  14. zhoom

    zhoom Peon

    Messages:
    388
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #14
    The other thing to check. Is the php relative filepath correct?
     
    zhoom, Jul 11, 2010 IP
  15. TeDWooD

    TeDWooD Member

    Messages:
    135
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #15
    Ok thanks i think i have cracked it now :)
    Managed to add the php and it worked.
    Thing is what do i do with my static html pages now. Just delete them?
    Also is there any code that i can use to add pages to my blog or can i just use the php include function?
     
    TeDWooD, Jul 17, 2010 IP
  16. zhoom

    zhoom Peon

    Messages:
    388
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Ok, glad you sorted it!!

    If you are only using the php pages now, you could just save your html files in a backup folder on your web server or computer. You never know when you might need to revert back! I rarely completely delete anything just in case!

    If you want to add a page, you will still need to create it. Theoretically you could custom code a full php website where the header, menu, footer, sidebar and content are all called with includes...But that would be unnecessary when you could just use a CMS like wordpress.

    There are a lot of free themes you can download and play with to figure out how wordpress works and lots of free tutorials and forums like this where you can get assistance. I would highly recommend trying wordpress as it is extremely powerful, especially with some of the new features in the recent 3.0 release.
     
    zhoom, Jul 17, 2010 IP
  17. TeDWooD

    TeDWooD Member

    Messages:
    135
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #17
    Thank you very much. I was looking at wordpress before and will definitely consider using it now.
    Reputation was added a few days ago for you friend :)
     
    TeDWooD, Jul 17, 2010 IP
  18. zhoom

    zhoom Peon

    Messages:
    388
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Most welcome! Good luck with your journey of discovery! :) And thanks for the reputation...
     
    zhoom, Jul 17, 2010 IP