TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 238
  • Total: 238

Tricky Block Request

Started by Xarcell, June 01, 2006, 04:18:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jacortina

Quote from: snoopy_inc on November 19, 2006, 11:39:48 AM
This code works perfectly in display on the main page.  100%  BUT  it is linking to unknown places.  IE The requested URL /forum/index.php20.0 was not found on this server. that is the error im getting.
When the board url for that one is something totally different.

Somone help me with this plz


ie
The requested URL /forum/index.php9.0 was not found on this server. from the code you gave me.

This is what it should be linking to
http://*****/forum/index.php/board,9.0.html

Any help on this would be much appriciated as this will help with getting new visitors to access the forums easier.
Thanks

While there WAS an error in the code given, I believe the format for board URL you're showing is for Search Engine Friendly URLS. I think that, if fixed, the regular URL's should also work, so try:

global $db_prefix, $context, $user_info, $scripturl;

if (!isset($context['jump_to']))
{
// Find the boards/cateogories they can see.
$request = db_query("
SELECT c.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.childLevel
FROM {$db_prefix}boards AS b
LEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)
WHERE $user_info[query_see_board]", __FILE__, __LINE__);
$context['jump_to'] = array();
$this_cat = array('id' => -1);
while ($row = mysql_fetch_assoc($request))
{
if ($this_cat['id'] != $row['ID_CAT'])
{
$this_cat = &$context['jump_to'][];
$this_cat['id'] = $row['ID_CAT'];
$this_cat['name'] = $row['catName'];
$this_cat['boards'] = array();
}

$this_cat['boards'][] = array(
'id' => $row['ID_BOARD'],
'name' => $row['boardName'],
'child_level' => $row['childLevel'],
'is_current' => isset($context['current_board']) && $row['ID_BOARD'] == $context['current_board']
);
}
mysql_free_result($request);
}

foreach ($context['jump_to'] as $category)
{
echo '<span class="smalltext" style="text-decoration: underline; font-weight: bold;">', $category['name'], '<br /></span>';
foreach ($category['boards'] as $board)
echo '<span class="smalltext"><a href="' . $scripturl . '?board=' . $board['id'] . '.0">'. str_repeat('..', $board['child_level'] + 1) . $board['name'] . '</a><br /></span>';
}

snoopy_inc

Thanks alot :)

Working like a charm now :D

I still cant believe how helpful this place is its AWESOME :)

J.A.Cortina thanks alot i really appriciate it

snoopy_inc

Any way i can change the way the text is shown?
Currently it looks like this
Boardindex
MAIN
..WebMasters
..Admin
..Banking
....Standard Bank
....FNB
....ABSA
....Nedbank
..Education
..Government & politics
..BEE

how can i add a button to it? make it with some nice text change the .. to - or something else i want to use? i would like to know how to customize this code if i need to.
Many thanks

jacortina

Quote from: snoopy_inc on November 19, 2006, 02:02:02 PM
Any way i can change the way the text is shown?

how can i add a button to it? make it with some nice text change the .. to - or something else i want to use? i would like to know how to customize this code if i need to.
Many thanks

Well, there are really only the two output statements:
echo '<span class="smalltext" style="text-decoration: underline; font-weight: bold;">', $category['name'], '<br /></span>';
AND
echo '<span class="smalltext"><a href="' . $scripturl . '?board=' . $board['id'] . '.0">'. str_repeat('..', $board['child_level'] + 1) . $board['name'] . '</a><br /></span>';


The first is for the Category 'headings'.

The second is for the individual board links and breaks down like:
echo '
<span class="smalltext">
<a href="' . $scripturl . '?board=' . $board['id'] . '.0">' .
str_repeat('..', $board['child_level'] + 1) . $board['name'] .
'</a><br />
</span>';


That "str_repeat('..', $board['child_level'] + 1)" puts out 2 periods per board level and the periods plus the name are made into a link. You can specify a graphic there, though different graphics per board would take some (perhaps significant) extra programming.

For example, at the top of the code change the 'global' spec and add the line:
global $db_prefix, $context, $user_info, $scripturl, $settings;

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';


Then change:
str_repeat('..', $board['child_level'] + 1)
TO
str_repeat($bullet, $board['child_level'] + 1)


That will put out a 'bullet' per board level in front of the Board name.

domino

Quote from: Jpg on August 23, 2006, 04:42:15 PM
I'm talking about the boards and the links.
http://www.galadoriaonline.com/
They put all the links and boards with their description in one block with pictures. That is how they set up the forum...I guess you can always make a menu though and just put links to all the boards...

Sorry for bringing up a old thread. galadoriaonline.com type of block is exactly what i need for my bare portal. Instead of trying to fill up the portal index with too much sql queries, i'd like to have something like that site. can you please point me to the right direction?

thanks

Xarcell

It's about more than I was asking. It's a nice snippet though.

How about just showing all the child boards with one particluar board. Such as board ID: 9 ?


ZarPrime

Quote from: J.A.Cortina on November 19, 2006, 02:31:24 PM
For example, at the top of the code change the 'global' spec and add the line:
global $db_prefix, $context, $user_info, $scripturl, $settings;

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';


Then change:
str_repeat('..', $board['child_level'] + 1)
TO
str_repeat($bullet, $board['child_level'] + 1)


That will put out a 'bullet' per board level in front of the Board name.

Hi J.A.C.,

I tried this but it is giving me links that go to non-existant url's.  I will temporarily enable this block on my frontpage for guests so you can look if you'd like at http://talesofthehavenexpanse.com/SMF-1/index.php.  It's a center block called "php test 2".

For instance, the link for "GM Announcements" should be http://talesofthehavenexpanse.com/SMF-1/index.php/board,17.html but this code makes the link http://talesofthehavenexpanse.com/SMF-1/index.php17.0 which, of course, is incorrect (bad link).  The code is ...
global $db_prefix, $context, $user_info, $scripturl, $settings;

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

if (!isset($context['jump_to']))
{
// Find the boards/cateogories they can see.
$request = db_query("
SELECT c.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.childLevel
FROM {$db_prefix}boards AS b
LEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)
WHERE $user_info[query_see_board]", __FILE__, __LINE__);
$context['jump_to'] = array();
$this_cat = array('id' => -1);
while ($row = mysql_fetch_assoc($request))
{
if ($this_cat['id'] != $row['ID_CAT'])
{
$this_cat = &$context['jump_to'][];
$this_cat['id'] = $row['ID_CAT'];
$this_cat['name'] = $row['catName'];
$this_cat['boards'] = array();
}

$this_cat['boards'][] = array(
'id' => $row['ID_BOARD'],
'name' => $row['boardName'],
'child_level' => $row['childLevel'],
'is_current' => isset($context['current_board']) && $row['ID_BOARD'] == $context['current_board']
);
}
mysql_free_result($request);
}

foreach ($context['jump_to'] as $category)
{
echo '<span class="smalltext" style="text-decoration: underline; font-weight: bold;">', $category['name'], '<br /></span>';
foreach ($category['boards'] as $board)
echo '<span class="smalltext"><a href="' . $scripturl . $board['id'] . '.0">'. str_repeat($bullet, $board['child_level'] + 1) . ' ' . $board['name'] . '</a><br /></span>';
}


Did I mess something up?  ::)

ZarPrime

jacortina

The echo line here is incorrect (missing the '?board='):

foreach ($category['boards'] as $board)
echo '<span class="smalltext"><a href="' . $scripturl . $board['id'] . '.0">'. str_repeat($bullet, $board['child_level'] + 1) . ' ' . $board['name'] . '</a><br /></span>';




From http://www.tinyportal.net/index.php?topic=5439.msg87910#msg87910 above:
foreach ($category['boards'] as $board)
echo '<span class="smalltext"><a href="' . $scripturl . '?board=' . $board['id'] . '.0">'. str_repeat('..', $board['child_level'] + 1) . $board['name'] . '</a><br /></span>';



Even though this yields normal URL's intead of the 'search-engine-friendly', they'll work fine.

ZarPrime

That you JA Cortina, and thank you also JPDeni, for all of your expertise on this one.  I managed to lose the link to this thread for a long time, but I finally got into this thing and got it looking the way I was wanting it to look on the Forum I am working on.

If it hadn't been for a post by Gourgi in another thread tonight, I might have never found this thread again. ;)

Anyway, I used this code, along with some other code that I added, in the featured article on my frontpage and it looks great.  I'm not finished adding code to it yet, but if you want to see what it looks like so far take a look at this link ---> http://talesofthehavenexpanse.com/SMF-1/index.php

Thanks Again,
ZarPrime

Rus

I like the idea of this block and I tried to make it into a table with 2 columns and failed miserably.  Would someone be able to do that for me?

This website is proudly hosted on Crocweb Cloud Website Hosting.