BP Blog 9.0 linking articles from other pages not with in the provided package

Posted at 2:15:59 PM in BP Blog (7) | Read count: 2087

On my site, I installed the BP Blog 9.0 package into it's own subdirectory and only put a link to the blog from the main page.  The intent was to later incorporate content from the blog into the pages on my main site.  My first project was to add the 10 most recent subjects to main page as hyperlinks.  The hyperlinks would open the blog page and display the entire article exactly is it would appear if opened from the main blog page.

In order to do this, I had to open the database and pull the subject lines for each article and sort them in date order, most recent being at the top.  I chose to do this with a saved query or view.  As I mentioned in a previous blog, I used Postgresql database backend on my installation off BP Blog.  Further more, the database server is located at a separate site from where the web server is.  This doesn't change anything in my project, I am just describing my working environment.  I get a lot of flack for setting up database servers separate from the web server, but I have never seen any problem with it.  When you are viewing this site, the config is just as I described my working environment here.

I created the view to pull the ID and blog title from the main blog data base and sorted it by date, limiting the selection to include only the articles that were not in draft.  Once I had this view saved, I was able to access the view just like I would a regular table.  I chose to pull all of the records and limit the number of records in the asp script.  Limiting is done differently in different databases, for example, in MS SQL it would be "top 10" and in postgres it would be "limit 10"

I then opened one of the asp pages that is normally used to display the blog text, default.asp (the one in the theme directory) works fine.  I copied the lines from the top and bottom of the asp scripts and pasted them into the appropriate places in my main page file.  This provided the connections file and the initial database pull. Then I replaced the SQL query text with my select statement which pulled from the view I had created and limited the output would be the 10 most recent entries.

I already had a list of projects on my main page which I was going to replace with this list.  The primary difference being that the new list would change everytime I added an article to my blog.  With this change my main page would now have changing content.  It's the most frequently hit page of all my pages and also the most frequently abandoned page.  The bullet format was already there, I just needed to replace the text and make them links.  Something like this is done in the blog pages, so I opened default.asp again (same one in the themes folder) and extracted the loop script.  I cut out the code that displayed the summary and changed the loop criterion to list everything instead of using the Dreamweaver pagination script that is in the default.asp.

That completed my project.  The only problem I ran into, besides typos in my editing was understanding how the script worked to pick the themes in BP Blog 9.0.  The main blog directory contains files that have exactly the same name as the themes directory.  The asp files in the main directory only open the database to determine the theme and then re-direct to the same named file in the theme directory.  Since my package was installed in a separate subdirectory, I had to modify the script copied to include the subdirectory I copied it to.  For example:  

<a href="/blog/template_permalink.asp?id=<%=(rsBlogSite.Fields.Item("BlogID").Value)%>

The first run I did, didn't work because I left it without the directory in bold.  I then put a link directly to the subdirectory which turned out a page without any of the CSS formating.  That didn't look good.  So I use the default.asp page to get the theme info and set the session variable in my main page, but that wasn't needed.  Each same named file in the blog directory also determines the theme you are using and sets that session variable and then calls executes the correct file in your themed directory.

That completes this project.

Written by Leonard Rogers on Thursday, February 24, 2011 | Comments (0)

    Email address is not published
    Remember Me

    CAPTCHA Reload
    Write the characters in the image above