-
How I updated my themes from .64 to .70 rogue.
(News)
-
The theme explanation mentions things like:
$info = genArticleInfo($row)
$results = getArticles(where, order, limit)
$links = genArticleLinks($info)
$preformat = genArticlePreformat($info, $links)
Screw that. I didn't need any of it. Try to follow these instructions, I appologize if they're kind of rambling... :) All themes are not made the same, so I can't into specifics, but if you figured out the old theme system, this is a piece of cake once you sit and work with it a bit.
First step.
BACK UP YOUR THEME! Once you update your functions they will not completely work until you finish updating each variable.
Next
Look through your theme. Anywhere you have a variable - such as $informant, $title, or $comments, more than likly you will replace it with either a call to $info[informant], $preformat[title], or $links[comment].
Now, a brief explanation of the differences between them:
Items in $info contain JUST test. No formating.
ex: $info[topicimage] is just "announcements.gif" (no quotes)
Items in $links contain just the URL. Again, no formating.
Items in $preformat are formatted and already contain links and everything. Very handy.
$preformat[title] already figured out story id, and title name and formats it so that it's already clickable
Here we go...
Look at function themearticle()
Remove everything in the parenthesis of themearticle() and replace it with "$links, $info, $preformat." It should now look like: function themearticle($links, $info, $preformat)
Ok, your theme will be completely broken for now. I hope you saved. I made one change at a time and checked the results. Things should start appearing one by one.
Replace each variable ($cid, $hometext, $notes, informant) with the corresponding variable below. Note: if you use any of the $info or $links variables you will probably have to use them along with HTML to get links or formatting.
for instance: modules.php?op=modload&name=News&file=article&sid=$sid&mode=&order=0 will become modules.php?op=modload&name=News&file=article&sid=$info[sid]&mode=&order=0 or use $preformat[title]
If you have lengthy sections of code for formatting your article body, changes are you can just use $preformat[fulltext]
Be creative. Once you do a few, you'll be amazed at how easy it actually is.
Admin Check
Instead of using if ($admin) for your [Edit] [Delete] lines, use the following bit of code:
if (authorised(0, $storyComponent, '::', ACCESS_ADMIN)) {
echo " [ < a href="admin.php?op=EditStory& sid=$info[sid]">"._EDIT."< /a> | < a href="admin.php?op=RemoveStory&sid=$info[sid]">"._DELETE."< /a> ]n";
}
Note: I added spaces in the < a href> and < /a> statements
List of variables from themes.postnuke.com:
$info variables are NOT formatted. They're just raw information from the database.
$info[bodytext] - the main text of the story
$info[briefdatetime] - short version of the date and time the story was published
$info[briefdate] - short version of the date the story was published
$info[catandtitle] - the category and title of the story, in the format 'Category: Title' if the story is in a particular category
$info[cid] - the ID of the category the story is in
$info[catid] - the ID of the category the story is in (deprecated)
$info[cattitle] - the name of the category the story is in
$info[comments] - the number of comments the story has
$info[fulltext] - home text, then body text, then notes
$info[hometext] - the header text of the story
$info[informant] - the person who submitted the story
$info[longdatetime] - long version of the date and time the story was published
$info[longdate] - long version of the date the story was published
$info[maintext] - home text, then body text
$info[notes] - any editorial notes on the story
$info[sid] - the story ID
$info[tid] - the topic ID
$info[topic] - the topic ID (deprecated)
$info[topicd] - the topic ID (deprecated)
$info[title] - the story title
$info[topicname] - the name of the topic
$info[topicimage] - pathname to the topic image
$info[topictext] - description of the topic
$info[unixtime] - the Unix timestamp of the story
$info[version] - the version of the array. This can be used to see if sepcific variabels exist in the array or not.
$info[withcomm] - if the story allows comments to be posted with it
$links variables are just that. Just the URL. They are not formated.
$links[category] - list of items in the same category as the story
$links[comment] - comments on the story
$links[fullarticle] - the story itself
$links[print] - print the story
$links[send] - send the story to a friend
$links[version] - the version of the array. This can be used to see if sepcific variabels exist in the array or not.
$preformat variables are basically plug and play (uhg! Sorry!) They're already formatted and ready to be clicked. All AutoLinks have been inserted and everything. You're probably use these the most.
$preformat[bodytext] - main body of text, including autolinks if any
$preformat[bytesmore] - 'bytes more' link (for back-compatibility)
$preformat[category] - list of items in the same category as the story
$preformat[cattitle] - the title of the story, preceded by it's category (if any)
$preformat[comment] - info on current number of comments
$preformat[fulltext] - home text, then body text, then notes
$preformat[hometext] - initial text, including autolinks if any
$preformat[maintext] - home text, then body text
$preformat[more] - single generic status link (for back-compatibility)
$preformat[notes] - any editorial notes on the story
$preformat[print] - print the story
$preformat[readmore] - 'read more' link
$preformat[send] - send the story to a friend
$preformat[title] - the title of the story
$preformat[version] - the version of the array. This can be used to see if specific variabels exist in the array or not.
The new theming system is VERY powerful, and once you realise the theory behind it, you see it's pretty easy.
I hope this helps someone.
Generated on January 10, 2002.
-
=-Rogue-= Theme Function
(News)
-
Obtaining Article Information, Links, and HTML Fragments
1. Getting raw article information
$results = getArticles(where, order, limit)
This function takes three parameters, and returns an array of arrays, each holding information on a particular article. The where, order, and limit variables do not need to specify their initial keywords.
Example:
$results = getArticles("topic=4", "counter DESC", "5");
this will get the five most-read articles in topic 4
Note that the information passed back is pretty much directly from the database. The only real exception to this is that some values are duplicated for backwards-compatibility. These are:
topicid = tid
topic = tid
catid = cid
2. Getting processed article information
$info = genArticleInfo($row)
This function takes a row as returned from getArticles() and does some simple parsing of it to make it more acceptable to PostNuke. The specific textfields created are listed in the user documentation for genArticleInfo(). The operations carried out on the array are as follows:
. add a number of date/time strings
. validate the informant string
. provide a 'Category: title' type article header
. sanitize (and transform) the article title and bodies
3. Getting article links
$links = genArticleLinks($info)
This function takes information as returned from genArticleInfo() and creates a number of links from it suitable both for themes and internal use. The specific links created are listed in the user documentation for genArticleLinks(). The links are 'pure', in that they are straight URLs and have no HTML tags around them.
4. Getting preformatted HTML
$preformat = genArticlePreformat($info, $links)
This function takes information as returned from genArticleInfo() and links as returned from genArticleLinks() and creates a number of preformatted HTML fragments suitable both for themes and internal use. The specific fragments created are listed int he user documentation for genArticlePreformat(). The fragments normally include formatting information and are complete and self-sufficient HTML.
5. Putting it all together
Here is a really simple example that gets a bunch of articles, generates, the relevant information, and uses it to print out a list of headlines.
// Get the latest 10 articles by author ID 5 in descending time order $articles = getArticles("aid=5", "time DESC", 10); foreach ($articles as $row) {
// Generate information for row
$info = genArticleInfo($row);
$links = genArticleLinks($info);
$preformat = genArticlePreformat($info, $links);
// Print a clickable title (with category, if any) and date of the
// story
echo "$preformat[catandtitle] ($info[briefdate])";
}
--------------------------------------------------------------------------------
PostNuke Theme Information
themeindex() and themearticle()
themeindex() and themearticle() take a number of legacy parameters, but also three arrays which hold pretty much all of the information that a user should need to create full-featured themes, and supercede the old parameters. The three separate arrays, and their current contents, are outlined below.
info
info holds raw information. Most of this comes direct from the database query on a story, however some extras are also added. info is guaranteed to have at least the following items:
. bodytext - the main text of the story
. briefdatetime - short version of the date and time the story was published
. briefdate - short version of the date the story was published
. catandtitle - the category and title of the story, in the format
'Category: Title', if the story is in a particular category
. cid - the ID of the category the story is in
. catid - the ID of the category the story is in (deprecated)
. cattitle - the name of the category the story is in
. comments - the number of comments the story has
. fulltext - home text, then body text, then notes
. hometext - the header text of the story
. informant - the person who submitted the story
. longdatetime - long version of the date and time the story was published
. longdate - long version of the date the story was published
. maintext - home text, then body text
. notes - any editorial notes on the story
. sid - the story ID
. tid - the topic ID
. topic - the topic ID (deprecated)
. topicd - the topic ID (deprecated)
. title - the story title
. topicname - the name of the topic
. topicimage - pathname to the topic image
. topictext - description of the topic
. unixtime - the Unix timestamp of the story
. version - the version of the array. This can be used to see if sepcific variabels exist in the array or not.
. withcomm - if the story allows comments to be posted with it
links
links holds a set of 'pure' URLs for a spcific story. These are used to provide ad-hoc links where required by the themer. links is guaranteed to have at least the following items:
. category - list of items in the same category as the story
. comment - comments on the story
. fullarticle - the story itself
. print - print the story
. send - send the story to a friend
. version - the version of the array. This can be used to see if sepcific variabels exist in the array or not.
preformat
preformat holds a set of pre-formatted HTML fragments that fit a standard format. These are generally considered 'intelligent', so for instance a preformat that contains a comments link will contain the correct text relating to how many comments have been previously posted. Pretty much all preformatted text contains URLs. preformat is guaranteed to have at least the following items:
. bodytext - main body of text, including autolinks if any
. bytesmore - 'bytes more' link (for back-compatibility)
. category - list of items in the same category as the story
. cattitle - the title of the story, preceded by it's category (if any)
. comment - info on current number of comments
. fulltext - home text, then body text, then notes
. hometext - initial text, including autolinks if any
. maintext - home text, then body text
. more - single generic status link (for back-compatibility)
. notes - any editorial notes on the story
. print - print the story
. readmore - 'read more' link
. send - send the story to a friend
. title - the title of the story
. version - the version of the array. This can be used to see if
sepcific variabels exist in the array or not.
Example
The PostNuke theme uses these arrays to generate a lot of content, please look at this as an example of how the arrays can be
Generated on November 25, 2001.
-
Workshop: Article system
(News)
-
importance of article system deserves to make a little brainstorming here I guess. This should be non-developers' help to developers.
I will try to give a list of things that I feel that they should be added, things that I found in articles, comments and forums of this site, but also things that are maybe nonsense and I didn't think about them to all details but someone might find out that it is not nonsense or might have another valuable idea based on this.
And I would like to ask you all to comment this article and say what you think about this list, try to add something more and try to make order based on their importance (maybe admin could create a poll?).
So...here we go:
article header
Let's start from the top. I feel that admins should have a tool to edit the header. Of course you can reach it by editing the source but PN is said to be also for those without any knowledge of PHP and MySQL. Maybe at least a manual what and how to edit is needed. (The problem is that every time you upgrade you have to edit those files again.)
  a)   I think that a lot of people would like the author's name to be shown instead of its nick (see my article). Nick does not really makes your site credible with serious information.
  b)   If you have a text that was not originally written for your site, you sometimes need to put older date (few years back) but it is not possible without editing database. Maybe it is a nonsense because it could make a mess - you would probably need two date options: "written on" and "posted (or inserted) on". You could choose if you want to use both or just one of them. What do you think?...
two (and more) authors
It happens... It is rare, I know, but sometimes there are two people that are authors of one single article. Then it is needed to show them both. I have no idea how to implement this probably admin would have add the second one). You will find it very useful when you meet the situation...
author overview
When you click on the author (it is not possible in PostNuke theme now, there is no link) you should get his(her) info. It means also some short text (introduction) and his e-mail as well as list of his articles (which you can get now already).
hometext and bodytext
Sometimes you add an article (for example a tale) when you do not want the hometext (prefix) to be shown on the article's page again because you use part of the article's text in prefix to show what is it about. And you do not want it on print page too. You can reach this editing the code again but I think that there should be an option when adding the article where you could tick where you want hometext and bodytext to be shown. Something like this:
        article's page      print page hometext           no                   no
bodytext           yes                   yes
I guess it shouldn't be so difficult to implement but there is a problem: PN uses the print page for AvantGo which means that you would not see prefix in this case. It would be needed to have a special AvantGo page that would be actually the same as it is now so that it shows both the texts.
related articles
At the end of each article you could there might be list of related articles from the site. I do not know how to chose them but manually.
related links
Similar as above. It could be somehow connected with Web Links section but not necessarily. It is good for the reader when he can click on related link where he can get something more. He shouldn't leave our site so the link should be opened to new window.
poll for each article
Well we have a polls now on the main page. Great feature but sometimes it would be great to have a poll for each article you publish. Don't you think so?
WYSIWYG editor for adding article
We have a plug-in Submit News via PDHTML. Why not to have it directly in admin section for adding new stories?
magazine/newspaper style layout
You can see this request in one of the latest articles.
news submitting without admin control
Comes from this article. It would probably need small change in user system so that admin
could give or deprive the rights to publish.
private/public articles (registered/anonymous)
Details here.
disable article
A feature that allows you disable publishing the article. It would be still in database but you cannot see it on the main page or its own page until you enable it again. (I guess it is possible to unite this with previous suggested feature.)
pictures in articles
Article here.
Now you have to do it your own provisional way. I have implemented pictures in my site this way. CSS is defined in article (.flow { float: right})
then I add this class to each image (class="flow"). I guess the default theme could have something like this in defined in style.css. It is a way but you should have an option to upload pictures directly when adding new story and have a possibility to choose a place of the picture.
subcategories and subsections
Read more.
There are probably even more things you would like to have in article system of the Great Post Nuke. Try to think and list them here. Try to comment these above. Maybe we will reach the ideal that developers will accept as a challenge.
P.S.: If this workshop is succesful why not to have them more often. What about having a workshop about user system next tim
Generated on September 14, 2001.