Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Using Extra Content positions to Manage Blocks  (Read 6593 times)

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Using Extra Content positions to Manage Blocks
« on: July 22, 2007, 06:25:41 PM »

A few days ago... I added a couple of new Extra Content Positions to my snews.php file in sNews 1.6 to give me two more content positioning options. I did this because I wanted to see how they might be used to manage individual blocks in the Left and Right columns of a 3-column template... in much the same way a full-blown phpNuke website template does.

The first step was looking for a decent 3-column template to work with as I did not want to create one from scratch. This isn't easy as there are not that many easy-to-port 3-column templates around for small CMSs like sNews. A bit of searching eventually led me to  Broadsheet by Darren.

While porting the Broadsheet template for sNews 1.6, I then inserted the new "Left Extra" and "Right Extra" function statements (the names of the 2 new extra functions in snews.php) into the template replacing the content in the Broadsheet template's index.html file... and saved the file as a new index.php file as we do with any new template file. As well, I copied the sNews-specific styles from the default style.css file into the new template's style.css file, and made several minor styling changes as required.

Creating and Including Blocks
We begin by adding a new blocks folder to the site's root directory (for online use, ensure the folder's permissions are set to 777). We then create any number of block-specific block-files as plain text files. You can create any block content you want with PHP and HTML scripts... such as a small calendar block... an announcement block... a clock block... a login block... a weather-feed block... ad blocks... you name it. Name your files as whatever.txt. You can upload your files to the site's blocks folder using the Files Management Panel. Here's an example of a simple block-file containing some links:
Quote
<div class="block">
<h4>Left Links Block</h4>
<ul>
<li><a href="#">Left Link 1</a></li>
<li><a href="#">Left Link 2</a></li>
<li><a href="#">Left Link 3</a></li>
<li><a href="#">Left Link 4</a></li>
<li><a href="#">Left Link 5</a></li>
</ul>
</div>

... and another containing the function statement that calls the login function... to display login status within a block:
Quote
<div class="block">
<h4>Login Status</h4>
<?php login_link(); ?>
</div>
The next step is to create a new "Left Extra" article... and you would do the same steps for a new "Right Extra" article. Decide which blocks you want to include in your "Left Extra" (left column). The following are just examples I used in my test-template, but you get the idea... you simply arrange the strings in the order you want them to appear in:
Quote
[include]blocks/linksblock.txt[/include]
[include]blocks/blocktest.txt[/include]
[include]blocks/blocktest.txt[/include]

And... of course... take the same approach when creating a new "Right Extra" article.

Before saving these "Extras"... be sure to scroll down and expand the Customize panel, and choose where you want these located. The neat thing is you can choose to have them display on all pages, just the home page, or just on any other category page... so you can have different blocks on different category pages. And... since you will have already included a custom title for each block within its own block-file, then you would also un-check the Display Title option so that you don't have a title displaying at the top of each column.

CSS NOTE: (Aug.29.07) The stylesheet used by the templated used in the example uses a division class to display the grey box each block is contained in. If you don't have it in your css stylesheet, add it in:
Quote
.block {
   background: #F5F6F6;
   color: #808080;
   padding: 10px;
   margin: 0 0 10px 0;
   border: 1px solid #ccc;
   }


You can see how well this works out in this 3-column template test. Of course... this procedure isn't automatic as it might be from a slick Blocks Admin Panel as is used in a phpNuke site but it's just fine once the prep work is done. This approach also keeps the site's overhead down by not requiring any additional administration panels. :)

A default copy of snews.php +2 more positions for sNews 1.6 is available for download for those who'd like to have 2 additional content position options.

You can also download an snews.php file with DOM's extra position (1) already added... or add your own extra content positions to sNews 1.6 using DOM's Mod Updated to 1.6 as your guide.
« Last Edit: August 30, 2007, 02:36:09 AM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

rivnet

  • Newbie
  • *
  • Karma: 0
  • Posts: 3
Re: Using Extra Content positions to Manage Blocks
« Reply #1 on: August 29, 2007, 04:45:52 PM »

I tried to include a txt file according to your recomendations but can't see the content of this file. Just nothing. No error messages... What could be wrong with including?
Logged

Joost

  • Guest
Re: Using Extra Content positions to Manage Blocks
« Reply #2 on: August 29, 2007, 06:07:19 PM »

include doesn't show a message when a (text)file cannot be found. Check the path of the file.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Using Extra Content positions to Manage Blocks
« Reply #3 on: August 30, 2007, 02:40:16 AM »

@ rivnet...
Provided you have your file(s) saved/uploaded into a blocks folder within the root of your sNews site (along side the index.php and snews.php files)... and your file(s) contain the stuff to be displayed using the correct html syntax, then the files will display accordingly using the include tags as shown.  ;)
NOTE - I added the css styling for the block division class, above in my first post, in case you don't have it in your stylesheet yet.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

rivnet

  • Newbie
  • *
  • Karma: 0
  • Posts: 3
Re: Using Extra Content positions to Manage Blocks
« Reply #4 on: September 19, 2007, 01:01:07 PM »

thank you. The problem was in the sNews package. I reinstall it and got all includes working :-)
Logged

rumblepup

  • Guest
Re: Using Extra Content positions to Manage Blocks
« Reply #5 on: November 19, 2007, 07:15:33 AM »

I'm completely new to sNews, so you would have to pardon my upfront criticism of this technique.  Having to load content from an txt file completely defeats the purpose of having a CMS.  Left and Right Columns or content areas should be as editable as the content in the main of the site.  Left and Right columns are not just for links, but for additional, supportive content. 

I thank you kindly for your effort in working on this solution.  However, in my opinion, it not only is not effective, but potentially welcoming immediate security issues as well. 
Logged

Joost

  • Guest
Re: Using Extra Content positions to Manage Blocks
« Reply #6 on: November 19, 2007, 07:47:21 AM »

Welcome rumblepup

Looking at it from the endusers (editors, administrators) point of view, you want full control. However webmasters or developers might dispute that. :)
Besides that, this is forum section is named  Exploring sNews Versatility. If a useful frontend feature is found, that needs to be edited quite often, someone will most likely develop a backend tool.

What's the point with security? Please explain.
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Using Extra Content positions to Manage Blocks
« Reply #7 on: November 19, 2007, 02:02:27 PM »

Welcome rumblepup.
Perhaps you might explain what positioning content has to do with security. First off, sNews provides three content positions in its default state - articles, pages, and the ability to add "extra" content to any given page or category page-group. The two extra content functions are essentially clones of the default "extra" position, adding two more locations in the template where "extra" content may be assigned & displayed.

The use of block files was explored here mainly as a way of showing users one way of including content... other than straight text... as a way of generating special-purpose blocks. Examples could be a weather block that displays weather notices from another site... or a polling script... or a set of links to pages within the site... or external links... etcetera. This has always been possible with the default sNews package.

It is also possible, if I install Philmoz's Function Insert mod, to insert function-names from customized functions to do specific things... such as automatically display all article links within a given category on a given set of category pages. In other words, if I have a category called "Cars & Trucks"... and I have 8 articles within that category... I can use Joost's Articles-in-Cat function to auto-generate a list of articles for any category. By inserting the function-name into an "extra" that only displays on the "Cars & Trucks" category, the extra will display links to all articles in that category on all pages within that category.

There are no security issues that I can see. Only the Admin can upload files to begin with... and insert include strings to display their contents. I should note, though, that there is no "need" to upload and include files in "extra" positions... it is just an option for exploration. Again, as Joost noted above... this particular forum is used to Explore sNews Versatility, which means what we share here are merely ideas for exploration.  :)
« Last Edit: November 19, 2007, 02:23:47 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

rumblepup

  • Guest
Re: Using Extra Content positions to Manage Blocks
« Reply #8 on: November 20, 2007, 06:13:06 AM »

My apologies to the forum.  After reading my post, I realized that I sounded brash and noob stoopid.  I apologize. 

It's my own fault really, because I added my two bent cents after at about 3AM my time, and did not "get" the gist of the discussion. Jeez, I could hardly recall my own name at the time.

I'm actually very impressed with sNews, and I'm currently working with understanding it more.

Which furthers my own point that I shouldn't have even tried to comment on your work, or sidetracked your discussion. 

Again, I apologize for my misunderstanding and diversion of the topic.

However, to answer your question about my concern with security.  (Although it's academic at this point)

A standard txt file, in my experience and opinion (at this point a debatable issue) is not a secure location to store any type of data, especially one that will appear on a page (defacement being the issue I would be scared of)  Let me site ahead of time that I know personally that there a plethora of security measures one can take to secure any file on a server, even a lowly text file.  Location, name, permissions, extension, etc, come to mind as just the first things that can be done.

However, as pointed out, this was an exploration of alternatives, so I again missed the mark of the discussion. 

So I thank you for your patience.  I will go sit in the corner now.

 
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Using Extra Content positions to Manage Blocks
« Reply #9 on: November 20, 2007, 03:14:59 PM »

No need to apologise... no offense taken. We all learn from each other by discussing development issues here in sNews-land.  :)
Your point on the security (or lack thereof) of plain text files in an easily accessible location is a good one. Any site developer would want to ensure that all sensitive files are not accessible... text files included.

As an example, I would not put my text files in a root folder/directory called "text files" or "files" for online use... that would be too easy for someone to locate. Rather... I would use an obscure folder-name... such as "novocane219"... or "nedro903"... something that isn't likely to be randomly included in a URL... if you see what I mean.

When we use "include" tags to include a file from that location... in a content textarea... it gets saved to the articles dbase table. The inclusion of the file's content is taken care of on the server... retrieved and assembled by PHP functions server-side... and the generated source code only shows the file's actual content... not the path to the source (the file itself). So where the file itself is located is never actually revealed.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU