Author |
Message |
joslynn
New Member


Joined: Jan 06, 2007
Posts: 8
|
Posted:
Mon Jul 23, 2007 8:25 am |
|
I am trying to figure out a way to either create a block or have someone show me how to create a block for my journal entries. I simply want something that shows the members on the site what the last five journal entries are and who made them. I only want there to be a link to the journal entry and not a link to the user profile name. I also want there to be a link to the entire journal page at the bottom of the block. There need not be dates or any other information than what I described above.
I've been trying to figure this out on my own, but either the instructions that I find are too thick for me, because I don't know how to write php code, or they don't give enough information for me to understand what they are referring to when they mention certain things. For instance things like $content, output, OpenTable, echo, $result, database abstraction (in regards to my website), or how to figure out what these are, where to find them and what to do with them once they are found. I mean, it seemed, at first like, it was going to be pretty straight forward, but when I decided to try this journal thing, I realized that I didn't know what I was doing at all.
So if someone could give me a hand I'd be appreciative. At first I tried to simply change some blocks that were similar to what I wanted, but I have no idea where to get the information from that I need to change those blocks and I don't know what to remove and what to keep.
Here is an image of what I'm looking for:
Please help if you can, I would be grateful!!!
~Joslynn~ |
|
|
|
 |
mars
Worker


Joined: Jul 08, 2006
Posts: 123
Location: Bloomsburg,Pennsylvania
|
Posted:
Mon Jul 23, 2007 2:11 pm |
|
For a simple one without the user name (which is a more complex sql query) create a file called Block-Top5_Journals.php and put the following code in it.
Code:
<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/************************************************************************/
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
global $prefix, $db;
$a = 1;
$result = $db->sql_query("SELECT jid,title FROM ".$prefix."_journal ORDER BY pdate DESC LIMIT 0,5");
while (list($jid, $title) = $db->sql_fetchrow($result)) {
$jid = intval($jid);
$title = stripslashes($title);
$title2 = ereg_replace("_", " ", $title);
$content .= "<strong><big>·</big></strong> $a: <a href=\"journal.html?amp;file=display&jid=$jid\">$title2</a><br />";
$a++;
}
?>
|
Then upload it to the blocks folder and create a new block with it in admin. |
_________________ Only registered users can see links on this board! Get registered or login! |
|
|
 |
Gremmie
Former Moderator in Good Standing

Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA
|
Posted:
Mon Jul 23, 2007 3:15 pm |
|
Nice. Note that the short links or something here on this site messed up the link in the above. It probably should be (minus the spaces)
modules.php ? name=journal
instead of journal.html |
_________________ Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module |
|
|
 |
Gremmie

|
Posted:
Mon Jul 23, 2007 3:17 pm |
|
joslynn, also you might want to google for the PHP-Nuke How-To as it explains a lot of your questions.
There is also a book by Paterson called "Building Websites with PHP-Nuke" that explains how to build modules, blocks, etc. |
|
|
|
 |
joslynn

|
Posted:
Mon Jul 23, 2007 3:43 pm |
|
Mars, thank you very much, I will give this a try. I guess I'm not all that concerned right now about who the user is. That is something I might be able to figure out later.
Gremmie, I have been reading the PHP-Nuke How-To and reading posts were people are trying to explain the how to's, but they don't really address where to actually find the $content, output, OpenTable, echo, $result, database abstraction information from. They simply seem to assume that I know where to look for the right html links for the content and where to look in the data base for the global preferences. I haven't seen anything that tells you where to find that information.
I have been searching for a mod like this or how to make one myself for the past two weeks and I just got frustrated with not finding anything.
So I appreciate all the posts and thanks so much!!!! |
|
|
|
 |
mars

|
Posted:
Mon Jul 23, 2007 5:09 pm |
|
Best thing to do for simple blocks is to open existing ones and see how they get the data and return it. |
|
|
|
 |
Gremmie

|
Posted:
Mon Jul 23, 2007 5:27 pm |
|
Well if you have any specific questions feel free to ask. I thought the How-To was pretty good compared to most online info.
Basically the job of a block is to produce a variable called $content. The contents of $content is the HTML code for the block. Every block in your blocks directory ultimately assigns a string to a PHP variable called $content, which Nuke outputs when it is time to "draw" the block.
echo is a PHP statement.
OpenTable/CloseTable are functions performed by your theme, usually in theme.php. |
|
|
|
 |
joslynn

|
Posted:
Tue Jul 24, 2007 6:57 am |
|
By the way, the block works really well. I had to change a couple of things, but it works. So thank you again!!!
Okay, so I understand some $content, but not others. For instance, when I was looking at other blocks to try to build this one, I ran into some $content that didn't make sense to me:
Code: $content .= "<tr><td align=\"left\">";
$content .= "<strong><big>ยท</big></strong>";
$content .= " <a href=\"modules.php?name=News&file=article&sid=".$sid."\">$title</a>";
$content .= "</td><td align=\"right\">";
$content .= "[ $comtotal "._COMMENTS." - $counter "._READS." ]";
$content .= "</td></tr>";
|
I know what the second one is saying, but where do you find all of the other information on your site. I know it's sort of like html, but what's with everything that has a $ before it. Where are they getting that information from and how do they know where to place it in the code?
Also, in regards to global this is what the code above that I just posted as as their global:
Code:global $prefix, $multilingual, $currentlang, $db;
|
And this is what you have for the journal block:
Code:global $prefix, $db;
|
Where did you find that information and how do you know that you only need $prefix and not $multilingual and $currentlang as well and other things? Where do you find the information that explains where you find this information from?
Also with this:
Code:$result = $db->sql_query("SELECT sid, title, comments, counter FROM " . $prefix . "_stories $querylang ORDER BY sid DESC LIMIT 0,5");
|
What does it actually mean? What is a $querylang? What does DESC mean? Descending? What does sid mean? I know it has something to do with articles or stories. Is that the story id?
I can copy a code, but that doesn't mean I know what any of it means or where to get the information from on my site or from mysql if that's where I should be getting the information.
If someone could help, I'd be appreciative.
~Joslynn~ |
|
|
|
 |
Gremmie

|
Posted:
Tue Jul 24, 2007 7:24 am |
|
Wow, you have a lot of questions! That's good! You might want to start reading the documentation at PHP.net to understand the language a bit better. The things with dollar signs in front of them are PHP variables. Nuke (unfortunately) has a ton of global variables, most of them are set in mainfile.php. Many of them are read from your site preferences database table.
$db is the global database object. It lets you execute SQL queries on your database to retrieve/update content for your site. You can start reading about SQL at the mysql website. They have nice documentation.
Don't worry if you feel overwhelmed by all this. It takes a while to absorb all of this. There are a lot of things to get your hands around: PHP, MySQL, HTML, CSS, and finally the Nuke architecture itself. The Nuke architecture is explained pretty well in the How-To and and in the Paterson book, but you really have to study the code to figure out the fine details.
You may also want to get a good book on PHP and MySQL combined (using them together to build websites). There are a ton of books on this subject. |
|
|
|
 |
joslynn

|
Posted:
Tue Jul 24, 2007 8:33 am |
|
Yeah, I'm sure I have more questions, but I couldn't think of them all. lol
Okay, so I can find global variables in the mainfile.php, does it tell me what they do or is that something that one of the references sites or books will cover?
I do feel a bit overwhelmed. I tried working with phpnuke a few years ago, but really didn't have a clue. Then I decided to try again with my new site. Everything works well, but I would like to understand it more. I understand HTML and CSS and can create those. My issue is with php and mysql. I have the mysql site bookmarked, but when I went there, I felt really confused. But I know I'll try again and see if I can make sense of it.
The more people are patient with my questions, the more confidence it gives me and everytime you post even a little something, things start making a little bit more sense. So I appreciate you taking the time to give me some places to check out and especially a book to read.
I will take what you say under advisement and if I have further questions, at least I know where to look first. Of course, I'll do a search before I post anything, but I know this site has tons of information.
Okay, I'm babbling, but what I want to say again is Thank You! I will try not to give up on this.  |
|
|
|
 |
Gremmie

|
Posted:
Tue Jul 24, 2007 10:29 am |
|
Well there is a lot to digest but it really isn't rocket science. Get a good book on building websites with PHP and MySQL and it will all start to make sense, eventually. Once you have a grasp at the basics you can start to figure out what Nuke is doing under the covers by examining the code. |
|
|
|
 |
mars

|
Posted:
Tue Jul 24, 2007 1:55 pm |
|
Joslyn,
Here is a better version, it includes the author name and also adds an additional sort based on the time of the post, so the actual most recent will be at the top.
Code:
<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/************************************************************************/
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
global $prefix, $db;
$a = 1;
$result = $db->sql_query("SELECT jid, aid, title FROM ".$prefix."_journal ORDER BY pdate DESC , ptime DESC LIMIT 0 , 5");
while (list($jid, $aid, $title) = $db->sql_fetchrow($result)) {
$jid = intval($jid);
$title = stripslashes($title);
$title2 = ereg_replace("_", " ", $title);
$aid2 = ereg_replace("_", " ", $aid);
$content .= "<strong><big>·</big></strong> $a: <a href=\"journal.html?amp;file=display&jid=$jid\">$title2</a><br />";
$content .= "<strong><big>·</big></strong> Author:$aid2<br />";
$a++;
}
?>
|
Be sure to correct the URL again as the shorturls here are messing it up.
 |
|
|
|
 |
joslynn

|
Posted:
Tue Jul 24, 2007 5:06 pm |
|
Excellent! Once again, thank you Mars!!!
Gremmie wrote: | Well there is a lot to digest but it really isn't rocket science. |
Yeah, I just need to set aside some time to digest this. I'm sure I'll get the gist of it eventually.
Cheers and thank you all again!!!
~Joslynn~ |
|
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Wed Jul 25, 2007 6:07 am |
|
No worries Joslynn. To anybody other than a professional programmer, this all will look like Greek to you and be overwhelming. Even a professional programmer has to take some time to learn the new syntax of a new language.
You'll get there. Just hang in there and do a ton of reading. Eventually, all the pieces will fall into place and then you'll be hooked on PHP/mySQL for life (that is a friendly warning. lol). |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
candy
Worker


Joined: Dec 21, 2004
Posts: 225
Location: Kansas City metro
|
Posted:
Mon Nov 05, 2007 3:59 pm |
|
Thank you for this block! LOVE IT! I do have one question though, how would i go about editing it if I wanted the block (center only) to display the user's avatar next to their entry and/or by the author's name? Thanks so much!!
mars wrote: | Joslyn,
Here is a better version, it includes the author name and also adds an additional sort based on the time of the post, so the actual most recent will be at the top.
Code:
<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/************************************************************************/
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
global $prefix, $db;
$a = 1;
$result = $db->sql_query("SELECT jid, aid, title FROM ".$prefix."_journal ORDER BY pdate DESC , ptime DESC LIMIT 0 , 5");
while (list($jid, $aid, $title) = $db->sql_fetchrow($result)) {
$jid = intval($jid);
$title = stripslashes($title);
$title2 = ereg_replace("_", " ", $title);
$aid2 = ereg_replace("_", " ", $aid);
$content .= "<strong><big>·</big></strong> $a: <a href=\"journal.html?amp;file=display&jid=$jid\">$title2</a><br />";
$content .= "<strong><big>·</big></strong> Author:$aid2<br />";
$a++;
}
?>
|
Be sure to correct the URL again as the shorturls here are messing it up.
|
|
|
|
|
 |
candy

|
Posted:
Fri Jan 18, 2008 10:48 pm |
|
this block is not working There have been several posts to the Journal that are not showing up and I just did a test post and it didn not have any effect on the TOP5 that are showing up either.
Any ideas on what might be going on? Thanks. |
|
|
|
 |
candy

|
Posted:
Sun Jan 20, 2008 12:24 am |
|
|
|
 |
|