TinyPortal

Development => Block Codes => Topic started by: Xarcell on June 01, 2006, 04:18:49 PM

Title: Tricky Block Request
Post by: Xarcell on June 01, 2006, 04:18:49 PM
I know this is gonna sound kinda crazy, but I've been trying to figure 2 things out.

1.| how can I show the latest boards within a category and or a whole list of boards within a board category.

2.| how can I show the latest members, within a secondary membergroup?

Any help would be appreciated.
Title: Re: Tricky Block Request
Post by: gbingo on August 23, 2006, 03:57:12 PM
l would like to know this as well - how to just list all of a forum's boards in a block.
Title: Re: Tricky Block Request
Post by: Jpg on August 23, 2006, 04:05:20 PM
Hmmm...There's a roster page...Maybe you can modify the code so it only shows the members name and not his info. Then you can order them by registration instead or alphabetical order.
Title: Re: Tricky Block Request
Post by: JPDeni on August 23, 2006, 04:24:05 PM
Quotehow to just list all of a forum's boards in a block.
I think I did something like this for someone else recently.

You just want to list the board names with links to the boards? And example is really helpful to understand exactly what you want. (I usually come up with something brilliant that is exactly the wrong thing. :) )


Title: Re: Tricky Block Request
Post by: gbingo on August 23, 2006, 04:35:05 PM
Exactly! Just list the board names, with links directly to the boards
Title: Re: Tricky Block Request
Post by: Jpg on August 23, 2006, 04:36:23 PM
Something like Galadoria online?
Title: Re: Tricky Block Request
Post by: gbingo on August 23, 2006, 04:38:27 PM
I don't know what Galadoria online is - but i guess your answering the second part of the OP's thread, not the first which is the one I am interested in ;)
Title: Re: Tricky Block Request
Post by: 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...
Title: Re: Tricky Block Request
Post by: gbingo on August 23, 2006, 04:45:49 PM
Worse case scenario i'll hardcode them but was hoping for a way to do it via SSI or PHP
Title: Re: Tricky Block Request
Post by: Jpg on August 23, 2006, 04:50:38 PM
Hmmm.... Do you want just a list?
Because you can put links like I said using a catmenu block.  ;)
Title: Re: Tricky Block Request
Post by: gbingo on August 23, 2006, 05:06:38 PM
Catmenu block? There is such a thing! Boy, do I feel like a newbie!  :laugh: I'll look into this now.
Title: Re: Tricky Block Request
Post by: JPDeni on August 23, 2006, 05:46:00 PM
The menu block is for articles. You want boards.


global $db_prefix, $scripturl;
$perm= $GLOBALS['user_info']['groups'][0];
if ($perm <>1)
  $where = 'WHERE FIND_IN_SET(' . "'" . $perm . "'" . ',memberGroups)';
else
  $where = '';

$query = db_query(
    "SELECT ID_BOARD, name
     FROM {$db_prefix}boards
     $where
     ORDER BY boardOrder", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
  echo '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '">'. $row['name'] . '</a><br />';
}


Tested in a php block. No errors.  :)
Title: Re: Tricky Block Request
Post by: Jpg on August 23, 2006, 06:50:16 PM
This works? Let me test it out. :)

Edit: Sadly it doesn't work. :(
Title: Re: Tricky Block Request
Post by: jacortina on August 24, 2006, 05:09:50 PM
The base code is pretty much already done in the loadJumpTo function of Load.php (which gets the arrays for the Jump To drop-down.


global $db_prefix, $context, $user_info;

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('..', $board['child_level'] + 1) . '&nbsp' . $board['name'] . '</a><br /></span>';
}
Title: Re: Tricky Block Request
Post by: JPDeni on August 24, 2006, 05:28:22 PM
Quote from: Jpg on August 23, 2006, 06:50:16 PM
Edit: Sadly it doesn't work. :(
It doesn't work? Or it doesn't do what you wanted it to do? It works, but I may have misunderstood what you wanted.
Title: Re: Tricky Block Request
Post by: Assistance on August 24, 2006, 09:18:22 PM
Quote from: jacortina on August 24, 2006, 05:09:50 PM
The base code is pretty much already done in the loadJumpTo function of Load.php (which gets the arrays for the Jump To drop-down.


thats cool code, but it shows ..&nbsp instead of space
Title: Re: Tricky Block Request
Post by: jacortina on August 24, 2006, 10:10:19 PM
Quote from: Assistance on August 24, 2006, 09:18:22 PM
thats cool code, but it shows ..&nbsp instead of space

Really?

Neither IE 6 nor FF on either of two PC's that I tried it on did that.

But you can just change that line in the code.
Title: Re: Tricky Block Request
Post by: Assistance on August 24, 2006, 11:05:38 PM
I have

and ty
Title: Re: Tricky Block Request
Post by: jacortina on August 25, 2006, 04:29:16 PM
I left out the global declaration for $scripturl.

Add that to the others in the first line or you'll get all sorts of errors logged (though the code works with that undefined).
Title: Re: Tricky Block Request
Post by: 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
Title: Re: Tricky Block Request
Post by: jacortina on November 19, 2006, 12:42:02 PM
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>';
}
Title: Re: Tricky Block Request
Post by: snoopy_inc on November 19, 2006, 01:44:42 PM
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
Title: Re: Tricky Block Request
Post by: snoopy_inc on November 19, 2006, 02:02:02 PM
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
Title: Re: Tricky Block Request
Post by: jacortina on November 19, 2006, 02:31:24 PM
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.
Title: Re: Tricky Block Request
Post by: domino on December 25, 2006, 12:07:18 PM
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
Title: Re: Tricky Block Request
Post by: Xarcell on December 25, 2006, 09:59:30 PM
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 ?

Title: Re: Tricky Block Request
Post by: ZarPrime on December 26, 2006, 10:03:42 AM
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 (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 (http://talesofthehavenexpanse.com/SMF-1/index.php/board,17.html) but this code makes the link http://talesofthehavenexpanse.com/SMF-1/index.php17.0 (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
Title: Re: Tricky Block Request
Post by: jacortina on December 26, 2006, 01:36:42 PM
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.
Title: Re: Tricky Block Request
Post by: ZarPrime on March 16, 2007, 12:17:58 AM
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 (http://talesofthehavenexpanse.com/SMF-1/index.php)

Thanks Again,
ZarPrime
Title: Re: Tricky Block Request
Post by: Rus on August 16, 2007, 08:31:58 PM
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?
Title: Re: Tricky Block Request
Post by: jacortina on August 17, 2007, 12:57:50 AM
You need something to be able to grab onto to trigger the 'break' from the first column (table cell) and the second.
Title: Re: Tricky Block Request
Post by: Rus on August 17, 2007, 01:36:56 AM
or perhaps go left, right, left right, under a category?
Title: Re: Tricky Block Request
Post by: jacortina on August 17, 2007, 01:45:22 AM
Well ... that's not how HTML works (and php puts out HTML; that's what it is, a hypertext preprocessor). You can't go back to a previous element that's already been output. You may (with a lot of work) do something to build each side and hold them in arrays/conacatentaed strings before then echoing those out.

But, it's hard to see how to retain the nesting of child/sub boards in that kind of presentation.
Title: Re: Tricky Block Request
Post by: Rus on August 17, 2007, 01:55:40 AM
Ahhhh, in my attempt I tried to use a table with 2 td and a tr and it didnt work.
Title: Re: Tricky Block Request
Post by: jacortina on August 17, 2007, 02:06:02 AM
That's the thing, you put something in the first td, then switch to the second and you can't really go back to the first.

That's why you'd have to cahce the output some way, building the two strings or arrays, and only after they're built do you output one to the first td and the other to the second td.
Title: Re: Tricky Block Request
Post by: JPDeni on August 17, 2007, 02:35:50 AM
Or you could have each item in its own cell:


item 1item 2
item 3item 4
item 5item 6
item 7item 8
item 9item 10
Title: Re: Tricky Block Request
Post by: Rus on August 17, 2007, 03:09:04 AM
thats what I tried but it kept failing before it output the first row
Title: Re: Tricky Block Request
Post by: JPDeni on August 17, 2007, 03:49:34 AM
I'd have to see your code in order to know what you did wrong.
Title: Re: Tricky Block Request
Post by: Rus on August 17, 2007, 05:26:37 AM
I got frustrated and deleted it already.  Basically I tried starting a table before the query used on page 2 of this thread and inside the while statement tried using a counter to make only 2 columns with with tds and then when the counter hit 2 reset it to 1 and put in a tr.

That didnt work.  Do you think you could make something that would work?
Title: Re: Tricky Block Request
Post by: IchBin on August 17, 2007, 06:15:29 AM
Here's some code I did hacked on for recent articles that gave 3 columns, then starts a new row. Perhaps that can help you understand how it works.

// ÃÅ"bersicht Tauchplätze österreich
global $db_prefix, $scripturl;

$category = 1; // Tauchplatzkategorie

$query = db_query(
    "SELECT id, subject
     FROM {$db_prefix}tp_articles
     WHERE category = $category
     AND off = 0
     AND approved = 1
     ORDER BY subject", __FILE__, __LINE__);
echo '<div style="overflow: auto; width: 100%;">';

$i = 0;

echo '<table cellspacing="0" cellpadding="0">
<tr>';
while ($row = mysql_fetch_assoc($query)){
  echo '<td style="padding-left: 20px;"><a href="' . $scripturl . '?page=' . $row['id'] . '">' . $row['subject'] . '</a></td>'; 
$i++;
if ($i > 2){
echo '</tr><tr>';
$i = 0;
}
}
echo '</tr></table>';
echo '</div>';
Title: Re: Tricky Block Request
Post by: Rus on August 17, 2007, 04:49:39 PM
Thank you, that showed me my error exactly.  Being completely new to PHP, I didnt know you needed to echo the table command.
Title: Re: Tricky Block Request
Post by: falguni1 on November 05, 2007, 11:30:14 AM
this is how it looks for those who dont know

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg67.imageshack.us%2Fimg67%2F8105%2Fmenund6.png&hash=900209b743b349e96a117366c56ddb4e5c417b37)
Title: Re: Tricky Block Request
Post by: falguni1 on November 05, 2007, 11:39:36 AM
this is one of the best snippets

I have a request as you can see I have many child boards and boards and it makes the menu very long

so can the menu be put in 2 columns like
1st column main boards
2nd column child boards

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg65.imageshack.us%2Fimg65%2F9409%2Fmenugm7.png&hash=9dd2a2dd2f204c98281660ebaac1e1df7a741e45)

and

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg261.imageshack.us%2Fimg261%2F7038%2Fmenujz2.png&hash=74a2a9f3421769adc9eae70e4ce99a80f5d7515a)

like the first column has boards (here all boards from the forum are seen but not child boards)
and the second column has child boards (which are seen when one clicks on the respective father board)
Title: Re: Tricky Block Request
Post by: RichardWing on November 16, 2007, 07:52:47 PM
Hello,

Did anyone come up with a 2 or 3 column center block solutions?

I am looking for a way to display a specific board title and then below it the last X amount of posts then do another board title in another column and x amount of last posts below it and repeat this in x amount of columns then move down and do the same for the next board I specify etc...

I guess I could wrap at the end of the main table and move down to the next row.

it would be cool if I could specify in an array or something all the boards we want to show in the center front page block from within the code.

Thanks,
Richard Wing
Title: Re: Tricky Block Request
Post by: Madisonianne on March 03, 2009, 01:39:18 AM
Hi...I've been reading through several of these snippet threads and haven't found what I'm looking for - but this comes pretty close...

I'm wanting a list of topics - not boards.  Even better if I can limit that list to just certain boards.  Make sense?  I hope!
Title: Re: Tricky Block Request
Post by: JPDeni on March 03, 2009, 01:59:38 AM
Can you describe exactly what you want, please? Pretend that nothing came before this -- that this is a completely new project.
Title: Re: Tricky Block Request
Post by: Madisonianne on March 03, 2009, 05:08:50 AM
Thanks for the fast reply! 

Well, ideally, I'd love to have something like this but listing the topics within the boards (as opposed to listing the boards within the categories).  I hope that makes sense!   I'm not sure how to post the code I saw that I liked, I'll give it a try.  Thanks!

Quoteglobal $db_prefix, $context, $user_info;

   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'], '
</span>';
      foreach ($category['boards'] as $board)
         echo '<span class="smalltext"><a href="' . $scripturl . $board['id'] . '.0">'. str_repeat('', $board['child_level'] + 1) . '' . $board['name'] . '</a>
</span>';
   }
Title: Re: Tricky Block Request
Post by: Madisonianne on March 03, 2009, 12:53:53 PM
I just found a good example!!!  It's here:

http://www.tinyportal.net/index.php?topic=27012.0

So now what I'd like is for this to be formatting in a table with the poster name and maybe the date. 

I am so sorry if I'm asking a lot!  I'm new to all this php stuff and need all the help I can get. :)  Thanks again!
Title: Re: Tricky Block Request
Post by: JPDeni on March 03, 2009, 02:11:52 PM
Okay. Let's start again. :)

What is it that you want? Don't compare it to anything else. Don't tell me what you don't want. Just what you do want. Pretend that no one on the planet has ever written anything that is remotely similar to what you want.

If you've written code that you want me to debug, that's a different thing. You'll have to tell me what the problem is, though.
Title: Re: Tricky Block Request
Post by: Madisonianne on March 03, 2009, 02:27:09 PM
:)  Sorry..I'll try again...

I'd like a list of topics from one specific board. 
I'd like it to include the name of the member who started it and the date.
I'd like it in a table.
I'd like it to be ordered descending from most recent topic.
I'd like the last 10.

I feel so bad...I hope this is better...and thank you!!!
Title: Re: Tricky Block Request
Post by: JPDeni on March 03, 2009, 03:24:02 PM
Don't feel bad. :) It's okay. I just get confused when I have to go from one thing to another in order to figure out what somebody wants. I need it all in one place. Like my sig file says "Explain it to me like I was a three-year-old." ;)

That shouldn't be too much. I'll see if I can get it out today.
Title: Re: Tricky Block Request
Post by: Madisonianne on March 03, 2009, 03:36:07 PM
 :uglystupid2:  I should know how it is - I do lots of tech support and I know how hard it is when people are all over the map trying to explain...

I've been trying to do this without asking for help - there is already SO much out here that I've not really needed - so I really appreciate that I get a response when I do finally ask!  You so rock!  (Actually, Tiny Portal does, too...things have gotten so much easier since I switched to TP!)
Title: Re: Tricky Block Request
Post by: JPDeni on March 03, 2009, 04:30:04 PM
TP is wonderful. That's why I give support here now. The script has done a lot for me and this is my way of giving back.

I understand about being a tech support person, though. I sometimes don't ask questions the way I should when I need help either. :)

Okay. This should do it, if I understand what you wanted:


global $db_prefix, $scripturl;

$board = 5;              // Set number of the board here
$number_to_display = 10; // You can change the number of topics that are displayed
$date_format = "j M Y";  // For displaying the date

// Links to first post in topic
// Order by the date of the first post in the topic
// List date topic was started
//////////////////////////////////////////////////////////////////////////////////
require_once("Subs.php");

$result = db_query("
SELECT m.ID_TOPIC, m.posterTime, m.subject, m.posterName, m.ID_MEMBER, t.ID_LAST_MSG
FROM {$db_prefix}topics as t, {$db_prefix}messages as m
WHERE t.ID_BOARD = $board
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT 10", __FILE__, __LINE__);

echo '<table>';
echo '<tr><td>Subject</td><td>Started by</td><td>Date</td></tr>';
while ($row = mysql_fetch_assoc($result)){
echo '<tr>';
echo '<td><a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '">'  . $row['subject'] . '</a></td>'; // Link to first message in topic
echo '<td><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'; // Started by
echo '<td>' . date($date_format,$row['posterTime']) . '</td>';
echo '<tr>';
}
mysql_free_result($result);
Title: Re: Tricky Block Request
Post by: Madisonianne on March 03, 2009, 07:55:51 PM
Argh!  My internet was down for hours but I'm back now and will give it a try and let you know how it goes.  No matter what, I very much appreciate all you've done!!!
Title: Re: Tricky Block Request
Post by: Madisonianne on March 03, 2009, 07:59:12 PM
How did you do that!?!  LOL  I love it!  Now all I need to know is if I can add more boards to it...if not, I'll work it out but just had to ask. 


Thank you so much - this is great!

(((I'm realizing I said what I wanted wrong (need a whole category or multiple boards), but this is great so thank you again!)))
Title: Re: Tricky Block Request
Post by: JPDeni on March 03, 2009, 08:34:40 PM
:) I've been doing this for a while. I still make a lot of mistakes, but this sort of thing is pretty straightforward.

There's different coding for a whole category or for different boards. This will give you different boards, but not necessarily all the boards in a given category. Put the board numbers into the $board array.


global $db_prefix, $scripturl;

$board = array(5,6,15);              // Set numbers of the boards here
$number_to_display = 10; // You can change the number of topics that are displayed
$date_format = "j M Y";  // For displaying the date

// Links to first post in topic
// Order by the date of the first post in the topic
// List date topic was started
//////////////////////////////////////////////////////////////////////////////////
require_once("Subs.php");

$where = '(t.ID_BOARD= ' . implode(' OR t.ID_BOARD=',$board) . ')';

$result = db_query("
SELECT m.ID_TOPIC, m.posterTime, m.subject, m.posterName, m.ID_MEMBER, t.ID_LAST_MSG
FROM {$db_prefix}topics as t, {$db_prefix}messages as m
WHERE $where
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT 10", __FILE__, __LINE__);

echo '<table>';
echo '<tr><td>Subject</td><td>Started by</td><td>Date</td></tr>';
while ($row = mysql_fetch_assoc($result)){
echo '<tr>';
echo '<td><a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '">'  . $row['subject'] . '</a></td>'; // Link to first message in topic
echo '<td><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'; // Started by
echo '<td>' . date($date_format,$row['posterTime']) . '</td>';
echo '<tr>';
}
mysql_free_result($result);


This does not check to be sure that the person is allowed to read that board. You'll have to take care of that yourself with block permissions, in case there are boards that you don't want everyone to see.
Title: Re: Tricky Block Request
Post by: Madisonianne on March 03, 2009, 10:03:05 PM
This is it - with all the right information in all the right places!  Now the only problem is that it's including the blocks around it for some reason  - I have no idea how that's happening!  Here's a screen shot:

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi557.photobucket.com%2Falbums%2Fss19%2FSweetSensations%2Fexample.gif&hash=4298ccc242809e41bf8b6c6c79c58fb2a7d4ac8e)
Title: Re: Tricky Block Request
Post by: JPDeni on March 03, 2009, 10:41:58 PM
The upper part is the code I wrote. What else do you have in that block? It looks like you somehow have a block within a block. This should go into a php block by itself.
Title: Re: Tricky Block Request
Post by: Madisonianne on March 03, 2009, 11:12:08 PM
Yes, the top part is what you wrote...And yes, it's in a separate block.  When I move the block from left to right to center - up or down - the same thing happens with the adjacent block.    This could only happen to me, I tell ya!  LOL
Title: Re: Tricky Block Request
Post by: JPDeni on March 04, 2009, 12:13:14 AM
It's my mistake. I forgot the closing table tag.

After

echo '<td>' . date($date_format,$row['posterTime']) . '</td>';
echo '<tr>';
}


add


echo '</table>';


(Actually, it was there originally, but it got deleted as I was debugging and I didn't get it back.)
Title: Re: Tricky Block Request
Post by: Madisonianne on March 04, 2009, 12:38:42 AM
Haha!!!  That was it!  You are so awesome - thank you SO much!  NOW I have the block I needed!    *does a happy dance*  (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fsweetsensationshome.com%2Fcommunity%2FSmileys%2Fclassic%2Fdance.gif&hash=3b82b325e97d512dfee88fb094ca30d6f8d18a89)

Thank you!!!
Title: Re: Tricky Block Request
Post by: JPDeni on March 04, 2009, 01:02:33 AM
LOL. I'm glad I was able to figure it out for you. :2funny:
Title: Re: Tricky Block Request
Post by: Madisonianne on March 04, 2009, 01:23:26 AM
It's great and I can't thank you enough!!!  I'm inspired to learn more now :)