PDA

View Full Version : vB Journal | vba CMPS module: latest entries


Bolas
09-24-2004, 10:00 PM
This hack is for [vB 3.0.3] - vB Journal for vBulletin 3.0.3(v1.0.0) and [vB 3.0.3]

Hi,
this is the Brahm's vbindex conversion for vba CMPS: this module will show latest journal entries in a box in your CMPS system.

demo:
http://www.wellage.net



Here we go:

touch /path_to_your_forum_dir/modules/journalentries.php
-----------------------------------------

<?php
// ######################### Latest Forum Topics #########################
$getlateste= $DB_site->query("
SELECT journal_entries.entrytitle,journal_entries.entryda te,
journal_entries.entry_id,journal_entries.entrytext ,
journal_entries.journal_id,journals.journalist,jou rnals.journalist_id
FROM ".TABLE_PREFIX."journal_entries AS journal_entries
LEFT JOIN ".TABLE_PREFIX."journals AS journals ON (journal_entries.journal_id=journals.journal_id)
WHERE journal_entries.entry_active=1 AND journal_entries.private!=1 AND journals.private!=1
ORDER BY journal_entries.entrydate DESC
LIMIT 5
");
$countlatest= $DB_site->num_rows($getlateste);
$latestentrybits = "";
if($countlatest>0)
{
while($latest= $DB_site->fetch_array($getlateste))
{
$latestentrydate= vbdate($vboptions['dateformat'], $latest['entrydate'], 1);
$latestentrytime= vbdate($vboptions['timeformat'], $latest['entrydate']);
exec_switch_bg();
if(strlen($latest[entrytitle])>20)
{
$latest[entrytitle]= "".substr($latest[entrytitle],0,20)."...";
}
if(strlen($latest[entrytext])>150)
{
$latest[entrytext]= "".substr($latest[entrytext],0,150)."...";
}
eval('$latestentrybits .= "' . fetch_template('journal_latestentrybits') . '";');
}
$DB_site->free_result($lastest);
}
else
{
$latestentrybits=$vbphrase['adv_no_entries'];
}


eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_latestjournalentry') . '";');

$DB_site->free_result($getlateste);
unset($latestentrybits,$latest,$latestentrytime,$l atestentrydate,$countlatest);

?>




then create template 'adv_portal_latestjournalentry'
-----------------------------------------

<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<thead>
<tr>
<td class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('cmps_pagesmenu')"><img id="collapseimg_cmps_pagesjournal" src="$stylevar/collapse_thead$vbcollapse[collapseimg_cmps_pagesjournal].gif" alt="" border="0" /></a>
<span class="smallfont"><strong>$vbphrase[adv_latest_journalentries]</strong></span>
</td>
</tr>
</thead>
<tbody id="collapseobj_cmps_pagesjournal" style="$vbcollapse[collapseobj_cmps_pagesjournal];text-align:$stylevar[left]">
$latestentrybits
</tbody>
</table>
<br />




Now add 2 GLOBAL phrases:
$vbphrase[adv_latest_journalentries] = "Latest Journal Entries"
$vbphrase[adv_no_entries] = "No Journal Entries"



Then create a new module:
Module Title: Journal Latest Entries
File to include: journalentries.php
Active: yes... -.-'
Column: right|left
Templates Used: adv_portal_latestjournalentry, journal_latestentrybits


Have fun and don't forget to https://vborg.vbsupport.ru/images/smoothblue/buttons/installed.gif (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=69862) :-)





UPDATE (10/17/2004):
- added 2 modified version of 'journal_latestentrybits' for right|left or center block (thanx to Billbensen for center version) - see attachments [ billbensen__centered_block.txt]
- Valentino Rossi Wins! :devious:

UPDATE (10/20/2004):
- patched template collapse id, please change your old template with new version. (thx to memobug for debugging)




thx to
AN-net for his Journal hack (https://vborg.vbsupport.ru/showthread.php?t=69538)
Brahm for the vBindex version of this module.
Billbensen for modified version of [i]journal_latestentrybits template

tomshawk
09-25-2004, 02:00 PM
Thanks Bolas

Once I install the journal system, I'll be installing this :p

BTW, I just want to verify

this line

LIMIT 5

in journalentries.php

If I want to only show the last one or two I just change it here, right?

Bolas
09-25-2004, 02:06 PM
yes it is! :-)

Also
---------------------------------

if(strlen($latest[entrytitle])>20)
{
$latest[entrytitle]= "".substr($latest[entrytitle],0,20)."...";
}
if(strlen($latest[entrytext])>150)
{
$latest[entrytext]= "".substr($latest[entrytext],0,150)."...";
}


...changing 20 (for the title) and 150 (for the text) you can choose the number of chars you want to display before the system cut it with "..."

tomshawk
09-25-2004, 02:21 PM
yes it is! :-)

Also
---------------------------------

if(strlen($latest[entrytitle])>20)
{
$latest[entrytitle]= "".substr($latest[entrytitle],0,20)."...";
}
if(strlen($latest[entrytext])>150)
{
$latest[entrytext]= "".substr($latest[entrytext],0,150)."...";
}


...changing 20 (for the title) and 150 (for the text) you can choose the number of chars you want to display before the system cut it with "..."
Excellent info, Thank you for converting this ;)

y2krazy
09-25-2004, 02:36 PM
/me clicks install!

Randall Rath
09-25-2004, 04:18 PM
Excellent instructions, thank-you!
I also thought I should mention that the SQL has a small problem on line 2 -

journal s.journalist_id

Should be,

journals.journalist_id

Probably just a format problem when it was pasted in, but it might catch some unaware.

Bolas
09-25-2004, 04:46 PM
Thank you! I edited the thread.

Moya
09-26-2004, 08:39 AM
After I add the mod, I got a white blank page.

Bolas
09-26-2004, 01:48 PM
try removing this mod totally (phrases, template and php).
Is all right now?
Ok.. re-install it following this new instruction (Randall found a format problem in SQL).

Now?

Polo
09-27-2004, 10:03 PM
thanks will install ;)

Moya
09-28-2004, 02:19 AM
Hi Bolas,

Thanks for this hack. There is something that I don't understand. This module causes a blank page when I tried to open my main page with Firefox. It works fine when I open it with IE

Bolas
09-28-2004, 08:10 AM
d'oh! I'm under Debian (unstable) and I use to browse ONLY with mozilla-firefox (now 0.9.x) ...
Also Epiphany, IE ( lol... ), Konqueror, lynx... and I don't have blank pages...
Try opening my vbulletin: http://www.wellage.net: te module is loaded on the bottom-right of the home page and works fine.
The module is just a chunk of php code and some html.. just a blank page? vBulletin in case of minor error (like a error in a module) doesn't stop his execution ( = blank page).

A) Does the needed template exists in the style you are using?

B) does your account have privis to receive that page? ( I mean... Are you logged with the same account of IE - check cookies - in Firefox? )

Without error messages I can't imagine what happens, but don't worry: we will find a solution! ;)




...


C) just to be sure... when you set unactive my module all works fine?

Wordplay
10-04-2004, 03:08 PM
sorry but i'm really slow with hacking. what are you supposed to place as the variables name when creating the phrases?

is it:
VARIABLES NAME: adv_latest_journalentries
TEXT: Latest Journal Entries

Bolas
10-04-2004, 03:42 PM
in /admincp, in the menu on the left:

Languages & Phrases
open section

Phrase Manager
click

on the right frame click Add New Phrase

in the new page (Add New Phrase)

Phrase Type: choose 'GLOBAL'
Varname: insert 'adv_latest_journalentries'
text: insert 'Latest Journal Entries' (and if you got another language installed fill it with right translation

SAVE



Say me if you need screenshot to follow step by step the single action! :)

bye!

Wordplay
10-09-2004, 02:26 AM
i have a little problem with this, the module shows up and it even includes the correct subjects of the latest journal entries, but the link is wrong for some reason. how can it pick out the right info but the wrong link?

the link will just be www.xxx.com/journal.php instead of www.xxx.com/forum/journal.php, how can i fix this?

Bolas
10-10-2004, 03:42 PM
open admincp/

choose your style (or default) and show template list.
open 'journal_latestentrybits'

find (or similar code.. the template is very little..)

href="forum/journal.php


replace it with

href="journal.php

Wordplay
10-11-2004, 10:38 AM
thanks alot! it was set to journal.php, i set it to the full link now it works!

billbensen
10-17-2004, 03:32 AM
for those of you that want this to be used in the center block.

This is the journal_latestentrybits

<tr>
<td class="$bgclass"><div class="smallfont"><a href="$vboptions[bburl]/journal.php?do=showentry&e=$latest[entry_id]" title="$latest[entrytext]">$latest[entrytitle]</a> - ($latestentrydate at <span class="time">$latestentrytime</span>)<br /><span style="cursor:pointer" onclick="window.open('member.php?u=$latest[journalist_id]')">$latest[journalist]</span></div></td>
<tr><td class="$bgclass"><div class="smallfont">$latest[entrytext]<a href="$vboptions[bburl]/journal.php?do=showentry&e=$latest[entry_id]" title="$latest[entrytext]">more</a></div></td></tr>
</tr>

It will display the short blurb of the journal entry and add a "more" link at the end.

Bolas
10-17-2004, 11:04 AM
I like it and make a different version insiperd of your version.
I updated the thread with your and mine versions (See attachments!)

Thank you! ;)

memobug
10-18-2004, 12:23 AM
Greetings

1. It looks like this is a typo, should probably be "latest"
}
$DB_site->free_result($lastest);
}
2. It is necessary to use stripslashes in a couple of places to prevent escaped quotes, i.e., Fred\'s Comment
Just inside the while loop add:

$latest[entrytitle]="".stripslashes($latest[entrytitle]);
$latest[entrytext]="".stripslashes($latest[entrytext]);

Don't ask me what the "". part is about, I'm just making it consistent with the existing code.

3. I added in a count of the comments in both the query and the templatebits

4. It would be very helpful if the hack installation instructions identify specifically (by link) which Journal it is intended for use. I think I have found about three threads that claim to be vbJournal and several versions of some.

At any rate it looks like it's incompatible with my version of "vbJournal" - now I have to figure out which version that is. Some port of Ryangel's hack I found on vbtemplates.org, I think.

5. I was able to modify the query and get everything to work with my version of the Journal, with the exception of this one parameter:

$latest[journalist], (journals.journalist), because that is a field I don't have in my database. I'm assuming that is the proper name of the Journal keeper, but I am a little surprised to see it in the journal table and not derived from the user table. If it were the username, it would be redundant and not necessarily subject to update if the username were changed.

:ermm:
Regards,

Matt

memobug
10-18-2004, 04:38 AM
Would it be possible to take only the most recent entry per journalist to avoid someone spamming the latest entries, so to speak? It seems like it should be possible with a GROUPing of some type, but the only solutions of this type I found online were sublinked queries that made my head hurt.

Regards,

Matt

Bolas
10-18-2004, 02:14 PM
Greetings
1. It looks like this is a typo, should probably be "latest"

Mumble... the error is in Billbensen modification of my add-on. I will send a mail to him to correct is code...
_______________________________

2. It is necessary to use stripslashes in a couple of places to prevent escaped quotes, i.e., Fred\'s Comment
Just inside the while loop add:

$latest[entrytitle]="".stripslashes($latest[entrytitle]);
$latest[entrytext]="".stripslashes($latest[entrytext]);

Don't ask me what the "". part is about, I'm just making it consistent with the existing code.

identical to 1.
_______________________________


3. I added in a count of the comments in both the query and the templatebits


nice, but use only an OL list?

<ol>
<li>blah<li>
</ol>

_______________________________

4. It would be very helpful if the hack installation instructions identify specifically (by link) which Journal it is intended for use. I think I have found about three threads that claim to be vbJournal and several versions of some.

At any rate it looks like it's incompatible with my version of "vbJournal" - now I have to figure out which version that is. Some port of Ryangel's hack I found on vbtemplates.org, I think.


At the end of the first post you can see the Thx Section:

thx to
AN-net for his Journal hack (https://vborg.vbsupport.ru/showthread.php?t=69538)
Brahm for the vBindex version of this module.
Billbensen for modified version of journal_latestentrybits template

...and also only one hack is called exactly vbJournal.
But you're right: I will change the title setting also hack version.. ;)
_______________________________


5. I was able to modify the query and get everything to work with my version of the Journal, with the exception of this one parameter:

$latest[journalist], (journals.journalist), because that is a field I don't have in my database. I'm assuming that is the proper name of the Journal keeper, but I am a little surprised to see it in the journal table and not derived from the user table. If it were the username, it would be redundant and not necessarily subject to update if the username were changed.


I only converted Brahm's vBindex version absolutely without modifying part of his code (I can't without explicit agreement).

Bolas
10-18-2004, 02:19 PM
I'm at lesson now and I can't try...
...but at your own risk ;) try this:



$getlateste= $DB_site->query("
SELECT journal_entries.entrytitle,journal_entries.entryda te,
journal_entries.entry_id,journal_entries.entrytext ,
journal_entries.journal_id,journals.journalist,jou rnals.journalist_id
FROM ".TABLE_PREFIX."journal_entries AS journal_entries
LEFT JOIN ".TABLE_PREFIX."journals AS journals ON (journal_entries.journal_id=journals.journal_id)
GROUP BY journal_entries.journal_id
WHERE journal_entries.entry_active=1 AND journal_entries.private!=1 AND journals.private!=1
ORDER BY journal_entries.entrydate DESC
LIMIT 5
");

billbensen
10-18-2004, 07:07 PM
Mumble... the error is in Billbensen modification of my add-on. I will send a mail to him to correct is code...

The typo is in the first part of the journalentries.php on the first post of this topic. I just carried it over when I made my changes. It's a free statement that really causes no harm, unless there were another call to that var. Just makes good coding sense to release them.

Bill Bensen

Bolas
10-18-2004, 07:20 PM
In fact! ;-)

billbensen
10-18-2004, 10:01 PM
The typo is from the original mod for vbindex. Both Bolas and I overlooked it. I think the strip slashes is a nice bit that was missed as well.

This hack is for [vB 3.0.3] - vB Journal for vBulletin 3.0.3(v1.0.0) and [vB 3.0.3] - vB Journal | vba CMPS module: latest entries

Below is the more blog like version of Bolas' mod. I am working on the RSS portion of this to make it even more "blog like". The entry title is 50 chars and the body of the entry is 150 chars and then the "more..." link to the entry.

Please note that this only shows the first jounalists' entries. On my site I only wanted my entries to appear on the front page. :glasses: You can change that by modifying the WHERE portion of the query "journals.journalist_id = 1" to whatever ID you wish to display or by removing it.

touch /path_to_your_forum_dir/modules/journalentries.php

<?php
// ######################### Latest Forum Topics #########################
$getlateste= $DB_site->query("SELECT journal_entries.entrytitle,journal_entries.entryda te,
journal_entries.entry_id,journal_entries.entrytext ,
journal_entries.journal_id,journals.journalist,jou rnals.journalist_id, journals.commentcount
FROM ".TABLE_PREFIX."journal_entries AS journal_entries
LEFT JOIN ".TABLE_PREFIX."journals AS journals ON (journal_entries.journal_id=journals.journal_id)
WHERE journal_entries.entry_active=1 AND journal_entries.private!=1 AND journals.private!=1 and journals.journalist_id = 1
ORDER BY journal_entries.entrydate DESC
LIMIT 5
");
$countlatest= $DB_site->num_rows($getlateste);
$latestentrybits = "";
if($countlatest>0)
{
while($latest= $DB_site->fetch_array($getlateste))
{
$latestentrydate= vbdate($vboptions['dateformat'], $latest['entrydate'], 1);
$latestentrytime= vbdate($vboptions['timeformat'], $latest['entrydate']);
exec_switch_bg();
if(strlen($latest[entrytitle])>20)
{
$latest[entrytitle]= "".substr($latest[entrytitle],0,50);
}
if(strlen($latest[entrytext])>150)
{
$latest[entrytext]= "".substr($latest[entrytext],0,200)."<div class='smallfont'><a href='$vboptions[bburl]/journal.php?do=showentry&e=$latest[entry_id]' title='$latest[entrytext]'>more...</a>";
}
eval('$latestentrybits .= "' . fetch_template('journal_latestentrybits') . '";');
}
$DB_site->free_result($latest);
}
else
{
$latestentrybits=$vbphrase['adv_no_entries'];
}


eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_latestjournalentry') . '";');

$DB_site->free_result($getlateste);
unset($latestentrybits,$latest,$latestentrytime,$l atestentrydate,$countlatest);

?>



then create template 'adv_portal_latestjournalentry'


<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<thead>
<tr>
<td class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('cmps_pagesmenu')"><img id="collapseimg_cmps_pagesmenu" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_cmps_pagesmenu].gif" alt="" border="0" /></a>
<span class="smallfont"><strong>$vbphrase[adv_latest_journalentries]</strong></span>
</td>
</tr>
</thead>
<tbody id="collapseobj_cmps_pagesmenu" style="$vbcollapse[collapseobj_cmps_pagesmenu];text-align:$stylevar[left]">
$latestentrybits
</tbody>
</table>
<br />


Modify the journal_latestentrybits

<tr>
<td class="$bgclass"><div class="smallfont">$latestentrydate </br><a href="$vboptions[bburl]/journal.php?do=showentry&e=$latest[entry_id]" ><b>$latest[entrytitle]</b></a> <br /></div></td>
<tr><td class="$bgclass"><blockquote><div class="smallfont">$latest[entrytext]</div></blockquote><span style="cursor:pointer" onclick="window.open('member.php?u=$latest[journalist_id]')">Posted by:&nbsp;$latest[journalist] </span>at <span class="time">$latestentrytime</span> ($latest[commentcount] comments)</td></tr>
</tr>

Now add 2 GLOBAL phrases:
$vbphrase[adv_latest_journalentries] = "Latest Journal Entries"
$vbphrase[adv_no_entries] = "No Journal Entries"



Then create a new module:
Module Title: Journal Latest Entries
File to include: journalentries.php
Active: yes
Column: center
Templates Used: adv_portal_latestjournalentry, journal_latestentrybits


Live example towards the bottom of the page. Surf this... photography (http://www.surfthisphotography.com)

This also displays the number of comments next to the author and the time the entry was added.

Bill Bensen

Bolas
10-19-2004, 08:18 AM
Good work!

If you want another example of the same Bilbensen modification to Bolas CMPS conversion of the Brahm's vBindex Add-On (please, we need another '..ation' to become the longest hackname of this forum :D) you can go to http://www.wellage.net
In my main page I used Billbensen mod to have a preview on the right side instead of a center block.

memobug
10-19-2004, 08:51 AM
Bolas, unrelated to this hack, there is a problem with your rollup code. The Journal button rolls up another ON FOCUS module. I had this problem and found I had to use unique names in five places (wherever you have ...cmps_pagesmenu substitute ...cmps_pagesjournal) in your journal template, I believe there are 5 occurrences) I can't guarantee that is the CORRECT solution, but that is what I did (give each module a unique cmps_pagesNAME) and the rollups worked independently.

Regards,

Matt

Bolas
10-19-2004, 06:46 PM
oh... deh...
It was so..ehm... funny! :D

Thank you, I will correct it ASAP!

Bolas
10-20-2004, 08:43 AM
done.

Roms
10-27-2004, 07:56 PM
Installed, works great! Thanks.

*Clicks Install

docvader
12-06-2004, 04:46 AM
Aaarrgh. I've tried installing this many times, and for some reason, it's the only CMPS module I can't get to show up on my main page, http://x.russbo.com/index.php
Vb3 Journal works fine, at http://x.russbo.com/vb/index.php
I don't understand why the journal works fine in the forums, but I can't get it to visualize on the CMPS page. I've followed the directions implicitly many a time.

Any idea where there might be a problem? No doubt it's something simple. Can I have a database problem which is causing this not to show, even though the Journal works fin in the forum???

docvader
12-06-2004, 04:50 AM
Aaarrgh. I've tried installing this many times, and for some reason, it's the only CMPS module I can't get to show up on my main page, http://x.russbo.com/index.php
Vb3 Journal works fine, at http://x.russbo.com/vb/index.php
I don't understand why the journal works fine in the forums, but I can't get it to visualize on the CMPS page. I've followed the directions implicitly many a time.

Any idea where there might be a problem? No doubt it's something simple. Can I have a database problem which is causing this not to show, even though the Journal works fin in the forum??? I'm completely baffled.

Thanks!

Lionel
03-08-2005, 04:02 PM
I have a small problem. At the end of my page I show a tag that is not closed: </html
And sometimes when I click on any link from that page, I get a blank page with >
When I refresh then it is fine.

I disabled the module and the tag disappeared. I re enabled, it came back....

I really need to use this. Any suggestions?

Bolas
03-08-2005, 05:46 PM
Have you modified the content of my module?

Lionel
03-08-2005, 08:56 PM
No not at all. It's pretty straight forward. I encounter a mysql issue twice: I am still at 3.23. I don't know if this has any relation whatsoever.

Bolas
03-08-2005, 11:06 PM
I installed again that hack, and it works fine.. and I don't know if to be happy or not for that :/
Is your vbAdvanced clean? Have you installed some plugin or hack for it?
It seems that a function cut 1 char.. and I'm not able to find the problem without have all the system under my hand!

Lionel
03-08-2005, 11:13 PM
clean? there is nothing to do in there, it's allmodules... :-)

if you want, I could pm you my info to see...

Bolas
03-09-2005, 12:17 AM
Yes, if you trust me. ;)
I will debug it in your system.

Zacharicus
04-30-2005, 05:33 AM
I'm assuming it doesn't work for 3.0.7? I can't get it to show up.

Bolas
05-01-2005, 01:05 AM
Uhm.. let me try on it.
I will reply to you in a few days.

Zacharicus
05-01-2005, 07:49 AM
Thanks, appreciate it!

Lionel
05-01-2005, 04:05 PM
My problem was extra spaces afyer the closing ?> tag

Bolas
05-01-2005, 04:24 PM
My problem was extra spaces afyer the closing ?> tag

I know, but I wasn't able to recreate the same error on my testing board, so I can assume that it depends by a custom config of you board.
Tonight I will install a clean 3.07 on my testing server, latest cmps vbadvanced hack and latest journal hack. Then I will try to install my module and I will fix all problems I will found.

Jaxx
07-02-2005, 12:06 AM
Where is the portion of the left and right blocks hack?

I would like to have mine there so its not hidden at bottom of the page, but I get all kinds of text in the side block from the journals. :/

:Judge:
07-18-2005, 06:41 AM
Need a way to add this to VBA 2 now.

swa
09-07-2005, 03:59 AM
is there anyway i can use this code to place it in the members profile?

digitalSite
09-18-2005, 08:21 AM
Will this hack work with CMPS 2.0? I am using vB 3.0.9. Thanks.