Advanced tricks

Can I show the last post of my Nucleus blog on a non-Nucleus page?

Scenario:
"I have Nucleus installed on my server and already have an existing home page that is in no way linked to Nucleus. I want to know how to show just the title and text of the last post on the homepage."

Original forum thread (thanks, ftruscot & trappedatuf!):
http://forum.nucleuscms.org/viewtopic.php?t=15049

Method:

  • Log in to your Nucleus admin panel and create a skin called "bare". Then edit the settings for that skin and in the "Main Index" skin part put this code:
    <%blog(bare/headlines,1)%>
  • Now go over to the templates section and create a new template called "bare/headlines". Once it is created click the edit button on it and enter this in the "Item Body" field:
    <a href="/path/to/index.php?itemid=<%itemid%>" title="<%title(attribute)%>">
    <b><%title%></b></a>
    <br><%syndicate_description(200)%>

    where /path/to/index.php is the directory where your Nucleus index.php lives relative to your home page file, i.e. if you have installed Nucleus in a subdirectory called /subdirectory/, you would put /subdirectory/index.php?itemid="<%itemid%>. If you installed Nucleus in your root directory, you would simply put index.php?itemid="<%itemid%>.

  • Create a file called headlines.php with the following code and put it in the same directory as your Nucleus index.php file:
    <?php
    // This file will generate and return the main page of the site
    $CONF['Self'] = 'headlines.php';
     
    include('content/config.php');
     
    selectSkin('bare');
    selector();
     
    ?>
  • In your home page, put the following code:
    <?php include('/path/to/headlines.php'); ?>

    where /path/to/headlines.php is the path to where your headlines.php file lives.

  • If you get a "headers already sent" error, edit the /nucleus/libs/globalfunctions.php file and change the following line to a zero:
    $CONF['alertOnHeadersSent'] = 0;
section: Advanced tricks | submitted by Leng on 2007.Feb.24 | 4790 views

item rate
Total votes: 10 - Rating: 5.40

Please tell us how useful this answer was to you (0 = useless, 10 = very very helpful):

10