How Do I Achieve this Simple Task (total noob)

Discussion in 'Programming' started by gder01, Apr 23, 2007.

  1. #1
    Lets say I have a website:

    Home Page
    Article Page
    Blog Page
    News Page


    The Home Page will have 4 sections in the body: the sections grab the latest entry from each of the 3 other pages (article, blog and news pages).

    Whenever I a make a new post/entry in the Articles, Blog, or News page, automatically on the main page it will update, and the user will see that there is new info posted. (The main page will have the title of the article as well as a slight intro, like the first 20 words of the article, and the it will say "read more")

    Will this take advanced programing? I really don't want to edit all the pages w/ HTML, because that will be very tedious.
     
    gder01, Apr 23, 2007 IP
  2. sundaybrew

    sundaybrew Numerati

    Messages:
    7,294
    Likes Received:
    1,260
    Best Answers:
    0
    Trophy Points:
    560
    #2
    You need a php script with functions
     
    sundaybrew, Apr 23, 2007 IP
  3. gder01

    gder01 Active Member

    Messages:
    262
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    oh okey, I had a hunch that was what I needed.
    Would it be easy to write one if I have no coding experience (besides a java class that I dropped)?

    Or are there any of these types of scripts that are free? If not, how much would a script like this cost?

    Thanks guys.
     
    gder01, Apr 23, 2007 IP
  4. pepsipunk

    pepsipunk Well-Known Member

    Messages:
    208
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #4
    It will be easy to code if the news posts and the blogs are all in a mysql database and the php script can just pull the data from that automatically
     
    pepsipunk, Apr 24, 2007 IP
  5. r72392

    r72392 Peon

    Messages:
    28
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    XML might be a solution to look at. The basic way of doing it is to create an xml document for each section (news, blogs, articles) formatted in a way similar to this:

    
    <news>
      <item>
        <title>[headline text]</title>
        <paragraph>[some text]</paragraph>
        <paragraph>[more text]</paragraph>
      </item>
    </news>
    
    Code (markup):
    After creating a document for each section of the site you need to make an XSLT document for each page you wish to present to the user. The xslt files transform the xml information into html files.

    The xslt files look something like this:

    
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:template match="news">
      <html>
        <body>
          <xsl:for-each select="item">
            <h2><xsl:value-of select="title" /></h2>
            <xsl:for-each select="paragraph">
              <p><xsl:value-of select="." /></p>
            </xsl:for-each>
          </xsl:for-each>
        </body>
      </html>
    </xsl:template>
    
    Code (markup):
    You save the xslt file as "news.xsl" and add the following line to the top of the "news.xml" file that was created earlier:

    
      <?xml-stylesheet type="text/xsl" href="news.xsl"?>
    
    Code (markup):
    That way the XML file knows which XSLT file is to be used to transform it into HTML.

    The xslt code looks a little dense but it gives you a lot of power when doing larger sites. It allows you to move all of the html code into a separate file and have a nice clean xml file that contains just content and any tags you wish to invent.

    To convert the xml to html you need to use an XML parser such as Saxon. You can choose to transform the xml on your own PC or I believe it is possible to have it done dynamically on the web server, although I haven't looked into that option.

    Once you convert the xml you end up with code like:

    
      <html>
        <body>
          <h2>[headline text]</h2>
          <p>[some text]</p>
          <p>[more text]</p>
        </body>
      </html>
    
    Code (markup):
    I've been using xml for a few months now and while it was difficult at first, it has really helped me be more productive. I'm finding it handy for writing help files where I have multiple product versions with similar help text (some versions need a few extra paragraphs here and there to explain the extra features). With xml I can just place text in an <advancedEditionOnly> tag and set a flag in the xslt to enable or disable it.
     
    r72392, Apr 24, 2007 IP
    gder01 likes this.
  6. gder01

    gder01 Active Member

    Messages:
    262
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #6
    thanks for the info above. I guess there are two approaches to achieving my goal then?

    Which approach would be more suitable for a noob like me, the php or the Xhtml? Are there any advantages to either one?

    Thanks r72392, for the help, I really appreciate it.
     
    gder01, Apr 24, 2007 IP
  7. r72392

    r72392 Peon

    Messages:
    28
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'd go with php to start with as it is a great language. Do the xml thing only if you have some spare time to stuff around with it.
     
    r72392, Apr 25, 2007 IP