Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
joslynn
New Member
New Member



Joined: Jan 06, 2007
Posts: 8

PostPosted: Mon Jul 23, 2007 8:25 am Reply with quote

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:

Image

Please help if you can, I would be grateful!!!

~Joslynn~
 
View user's profile Send private message
mars
Worker
Worker



Joined: Jul 08, 2006
Posts: 123
Location: Bloomsburg,Pennsylvania

PostPosted: Mon Jul 23, 2007 2:11 pm Reply with quote

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>&middot;</big></strong>&nbsp;$a: <a href=\"journal.html?amp;file=display&amp;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! 
View user's profile Send private message Visit poster's website
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Mon Jul 23, 2007 3:15 pm Reply with quote

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 
View user's profile Send private message
Gremmie







PostPosted: Mon Jul 23, 2007 3:17 pm Reply with quote

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







PostPosted: Mon Jul 23, 2007 3:43 pm Reply with quote

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







PostPosted: Mon Jul 23, 2007 5:09 pm Reply with quote

Best thing to do for simple blocks is to open existing ones and see how they get the data and return it.
 
Gremmie







PostPosted: Mon Jul 23, 2007 5:27 pm Reply with quote

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







PostPosted: Tue Jul 24, 2007 6:57 am Reply with quote

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&amp;file=article&amp;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







PostPosted: Tue Jul 24, 2007 7:24 am Reply with quote

Wow, you have a lot of questions! That's good! Smile 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







PostPosted: Tue Jul 24, 2007 8:33 am Reply with quote

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. Smile
 
Gremmie







PostPosted: Tue Jul 24, 2007 10:29 am Reply with quote

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. Smile 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







PostPosted: Tue Jul 24, 2007 1:55 pm Reply with quote

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>&middot;</big></strong>&nbsp;$a: <a href=\"journal.html?amp;file=display&amp;jid=$jid\">$title2</a><br />";
   $content .= "<strong><big>&middot;</big></strong>&nbsp;Author:$aid2<br />";
    $a++;
}
?>


Be sure to correct the URL again as the shorturls here are messing it up.
Very Happy
 
joslynn







PostPosted: Tue Jul 24, 2007 5:06 pm Reply with quote

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

PostPosted: Wed Jul 25, 2007 6:07 am Reply with quote

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! 
View user's profile Send private message Visit poster's website
candy
Worker
Worker



Joined: Dec 21, 2004
Posts: 225
Location: Kansas City metro

PostPosted: Mon Nov 05, 2007 3:59 pm Reply with quote

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!! Smile

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>&middot;</big></strong>&nbsp;$a: <a href=\"journal.html?amp;file=display&amp;jid=$jid\">$title2</a><br />";
   $content .= "<strong><big>&middot;</big></strong>&nbsp;Author:$aid2<br />";
    $a++;
}
?>


Be sure to correct the URL again as the shorturls here are messing it up.
Very Happy
 
View user's profile Send private message
candy







PostPosted: Fri Jan 18, 2008 10:48 pm Reply with quote

this block is not working Sad 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







PostPosted: Sun Jan 20, 2008 12:24 am Reply with quote

nevermind....solved....
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©