Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 04:14 am EST
Geeklog Forums
Need Help on a Simple Hack!
Anonymous
Anonymous
I know little of PHP/MYSQL (except what I've picked up by installing geeklog today. I love this thing!)
I'm writing a simple hack. I want each topic to have a topic header (i.e. a title) and two intro text fields. I've managed to add the three fields (topicheading, topicintro1 and topicintro2) to the gl_topic table. I have hacked the topic.php file to allow data input to the new fields. All this works very fine.
I want the text in these fields to display at the top of the first page of each topic. I've whacked at it and got it kinda working. But it needs to be done better.
THREE QUESTIONS????1. Where should I do the query on gl_topic to pull in the data in the new fields?
2. Where should I put the display code to display this data?
3. AND finally (if you are really generous), what would the needed code look like?
I don't want to just throw in a goofy kludge. I'd like to do something that when I am finished, I might upload and others here might want to use.
Hope you guys and gals will help.
And thanks to the developers for putting together such an excellent thing! I have been studying the code all day. I love how you folks have put geeklog together. So elegant.
14
10
Quote
Status: offline
rawdata
Forum User
Full Member
Registered: 02/17/03
Posts: 236
1. Where should I do the query on gl_topic to pull in the data in the new fields?
In index.php.
2. Where should I put the display code to display this data?
In index.php. If you want to display it regardless of whether there are stories, I would say try putting it above this section of code:
if ($nrows > 0) {
for ($x = 1; $x <= $nrows; $x++) {
$A = DB_fetchArray($result);
If you want it to display only if there is at least one story, then put it right after the: if ($nrows > 0) { and above the for loop.
3. AND finally (if you are really generous), what would the needed code look like?
Hey, if you've gotten this far, you're doing very well. So, why don't you take a shot at finishing it yourself first.
In index.php.
2. Where should I put the display code to display this data?
In index.php. If you want to display it regardless of whether there are stories, I would say try putting it above this section of code:
Text Formatted Code
if ($nrows > 0) {
for ($x = 1; $x <= $nrows; $x++) {
$A = DB_fetchArray($result);
3. AND finally (if you are really generous), what would the needed code look like?
Hey, if you've gotten this far, you're doing very well. So, why don't you take a shot at finishing it yourself first.
8
8
Quote
Anonymous
Anonymous
Excellent. Thanks for the help. Ironically I have the index.php file open right at this moment and was looking at precisely this section of code. I had already determined to put the query and display where you've described. The clue was in the "$display .= COM_article($A,'y');" where the article is apparently being displayed.
But I thought it would be a bit more efficient to read the topicheading, intro1 & 2 field data at the point where the topic name is first read (since the topic name is obviously being read anyway). Unfortunately I can't exactly find where that is.
Also, I didn't know if reading the heading fields from the topic file each time an article is displayed was good coding. It means each time a story is first displayed, the topic table AND THEN the story table will be hit (when in fact I only really need read the topic heading stuff once). Maybe I'm making a big deal outta nothing. I just wanted not to embarrass myself once people finally see the code.
Since I wish the intro stuff to show up on the first page of a topic, I will basically do something like this:
if $page == 1 {
do the query and display the heading stuff;
}
Hope this sounds reasonable. This undoubtedly simple stuff for you folks here. But, you see, PHP is almost complete gobbledegook to me. So I wanna make sure that when I do any sort of coding, I maintain the style you folks have established.
Thanks again for the reply.
8
10
Quote
Status: offline
rawdata
Forum User
Full Member
Registered: 02/17/03
Posts: 236
Yes, it would be more efficient to do it where the topic is first read and pass the info to index.php. Sometimes it's better to sacrifice an extra database call though so you don't have to modify too much of the original code. If the info you're passing is significant in size, it'll cause a delay in passing it anyway. In which case, the extra database call may turn out to be faster. If you only want it on the first page, you're on the right track in adding a conditional statement.
For someone who thinks this is all "gobbledegook", you're doing extremely well in your logic.
9
9
Quote
Anonymous
Anonymous
Well, thanks for the compliment. I logged on to gleefully report that my hack finally works, and I discovered someone posted a link to a much simpler and elegant solution using staticpages. I tested the static page solution and it works. So I'll use it. I had hoped to make my first "contribution" to the community. Oh well.
I'm still glad I completed my hack, even if I won't be using it. I learned a lot about Geeklog, PHP & Mysql.
Thanks for your help and kindness.
9
10
Quote
Anonymous
Anonymous
Yup! Thanks very much for bringing my attention to this. It works like a charm!
12
12
Quote
All times are EST. The time is now 04:14 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content