Seite 1 von 1

Coding Problem bitte helfen

Verfasst: 24.05.2004 21:30
von holzmichl
Hi Leute,

ich versuche grade die News Kategorien aus dem Slash News Mod darstellen zu lassen. Grundsätzlich klappt es, allerdings werden sie alle untereinander dargestellt, ich möchte aber nicht alle untereinander, sondern immer 4 nebeneinander darstellen lassen, dann in die nächste Zeile springen, dort die nächsten 4 anzeigen lassen, bis das Ende erreicht ist. Was muss ich am Code ändern ?

Das ist momentan in der php-datei:

Code: Alles auswählen

for($i = 0; $i < count($news_cats); $i++)
  {
    //
    // Replace htmlentites for < and > with actual character.
    //

    $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
    $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

    $template->assign_block_vars("news_cats", array(
      'ROW_COLOR' => '#' . $row_color,
      'ROW_CLASS' => $row_class,

      'TOPIC_COUNT' => $news_cats[$i]['topic_count'],

      'CATEGORY_IMG' => $phpbb_root_path . $board_config['news_path'] . '/' . $news_cats[$i]['news_image'],
      'L_CATEGORY' => $news_cats[$i]['news_category'],

      'U_NEWS_EDIT' => append_sid("admin_news_cats.$phpEx?mode=edit&id=" . $news_cats[$i]['news_id']),
      'U_NEWS_DELETE' => append_sid("admin_news_cats.$phpEx?mode=delete&id=" . $news_cats[$i]['news_id']))
    );
  }
und das ist momentan im tpl file:

Code: Alles auswählen

<table cellspacing="1" cellpadding="4" border="0" align="left" class="forumline">
  <tr>
    <th class="thCornerL">{L_ICON}</th>
  </tr>
  <!-- BEGIN news_cats -->
  <tr>
    <td class="{news_cats.ROW_CLASS}" align="center"><img src="{news_cats.CATEGORY_IMG}" alt="{news_cats.L_CATEGORY}" /><br />{news_cats.L_CATEGORY}</td>
  </tr>
  <!-- END news_cats -->
  <tr>
    <td class="cat" colspan="4" align="center">&nbsp;</td>
  </tr>
</table>
Hilfe :cry:

Thanks
Michl

Verfasst: 24.05.2004 21:50
von Lord_Femto

Code: Alles auswählen

<table cellspacing="1" cellpadding="4" border="0" align="left" class="forumline"> 
  <tr> 
    <th class="thCornerL">{L_ICON}</th> 
  </tr> 
  <!-- BEGIN news_cats --> 
  <tr> 
    <td class="{news_cats.ROW_CLASS}" align="center"><img src="{news_cats.CATEGORY_IMG}" alt="{news_cats.L_CATEGORY}" />{news_cats.L_CATEGORY}</td> 
  </tr> 
  <!-- END news_cats --> 
  <tr> 
    <td class="cat" colspan="4" align="center">&nbsp;</td> 
  </tr> 
</table>
im template ersetzen

Verfasst: 24.05.2004 21:54
von holzmichl
Öhm....

netter Versuch, das ändert aber so gut wie gar nichts, ausser das die Beschreibung hinter dem Kategoriebild steht, anstatt darunter. Der PHP-Code muss so geändert werden, das pro Zeile 4 Kategorien ausgespuckt werden, ich weiss aber nicht wie. Evtl. muss auch noch was im tpl file gemacht werden.

Thanks
Michl

Verfasst: 24.05.2004 22:30
von andreasOymann
Schau dir mal den Code in Smartor´s Album an, dort wird mit Bildern pro Zeile gearbeitet, und nach X Bildern beginnt ne neue Zeile. Den Code findest du in der album_cat.php ...

Verfasst: 24.05.2004 23:21
von holzmichl
Hi,

danke für den Tip, wenn ich den Code benutze dann habe ich die gewünschten 4 Felder pro Zeile, aber bei mir wird dann in den 4 Feldern der jeweiligen Zeile das gleiche Kategorie-Bild angezeigt.

Also ich habe 12 News-Kategorien, die jeweils 1 zugehöriges Image haben, und ich möchte diese 12 Images darstellen, undzwar pro Zeile jeweils 4 Stück. Also 1. Zeile Kategorie 1-4, 2. Zeile Kategorie 5-8 usw.

Momentan habe ich 1. Zeile (4 mal Kategorie 1), 2. Zeile (4 mal Kategorie 2) usw. Es werden insgesamt soviele Images angezeigt, wie ich Kategorien habe ;)

Irgendwo ist da der Wurm drin, ich weiss nur nicht wo :-?

Code: Alles auswählen

for ($i = 0; $i < count($news_cats); $i += $news_config['cols_per_page'])
  {
  	$template->assign_block_vars('picrow', array());
  	
  	for ($j = $i; $j < ($i + $news_config['cols_per_page']); $j++)
  	{
  		if( $j >= count($news_cats) )
			{
				break;
			}
  $template->assign_block_vars('picrow.piccol', array(
				'U_PIC' => ($album_config['fullpic_popup']) ? append_sid("album_pic.$phpEx?pic_id=". $picrow[$j]['pic_id']) : append_sid("album_page.$phpEx?pic_id=". $picrow[$j]['pic_id']),
				'THUMBNAIL' => append_sid("album_thumbnail.$phpEx?pic_id=". $picrow[$j]['pic_id']),
				'DESC' => $picrow[$j]['pic_desc'],
				'CATEGORY_IMG' => $phpbb_root_path . $board_config['news_path'] . '/' . $news_cats[$i]['news_image'],
      				'L_CATEGORY' => $news_cats[$i]['news_category'],
				'APPROVAL' => $approval_link,
				)
			);
$template->assign_block_vars('picrow.pic_detail', array(
				'TITLE' => $picrow[$j]['pic_title'],
				'POSTER' => $pic_poster,
				'TIME' => create_date($board_config['default_dateformat'], $picrow[$j]['pic_time'], $board_config['board_timezone']),

				'VIEW' => $picrow[$j]['pic_view_count'],

				'RATING' => ($album_config['rate'] == 1) ? ( '<a href="'. append_sid("album_rate.$phpEx?pic_id=". $picrow[$j]['pic_id']) . '">' . $lang['Rating'] . '</a>: ' . $picrow[$j]['rating'] . '<br />') : '',

				'COMMENTS' => ($album_config['comment'] == 1) ? ( '<a href="'. append_sid("album_comment.$phpEx?pic_id=". $picrow[$j]['pic_id']) . '">' . $lang['Comments'] . '</a>: ' . $picrow[$j]['comments'] . '<br />') : '',

				'EDIT' => ( ( $auth_data['edit'] and ($picrow[$j]['pic_user_id'] == $userdata['user_id']) ) or ($auth_data['moderator'] and ($thiscat['cat_edit_level'] != ALBUM_ADMIN) ) or ($userdata['user_level'] == ADMIN) ) ? '<a href="'. append_sid("album_edit.$phpEx?pic_id=". $picrow[$j]['pic_id']) . '">' . $lang['Edit_pic'] . '</a>' : '',

				'DELETE' => ( ( $auth_data['delete'] and ($picrow[$j]['pic_user_id'] == $userdata['user_id']) ) or ($auth_data['moderator'] and ($thiscat['cat_delete_level'] != ALBUM_ADMIN) ) or ($userdata['user_level'] == ADMIN) ) ? '<a href="'. append_sid("album_delete.$phpEx?pic_id=". $picrow[$j]['pic_id']) . '">' . $lang['Delete_pic'] . '</a>' : '',

				'MOVE' => ($auth_data['moderator']) ? '<a href="'. append_sid("album_modcp.$phpEx?mode=move&pic_id=". $picrow[$j]['pic_id']) .'">'. $lang['Move'] .'</a>' : '',

				'LOCK' => ($auth_data['moderator']) ? '<a href="'. append_sid("album_modcp.$phpEx?mode=". (($picrow[$j]['pic_lock'] == 0) ? 'lock' : 'unlock') ."&pic_id=". $picrow[$j]['pic_id']) .'">'. (($picrow[$j]['pic_lock'] == 0) ? $lang['Lock'] : $lang['Unlock']) .'</a>' : '',

				'IP' => ($userdata['user_level'] == ADMIN) ? $lang['IP_Address'] . ': <a href="http://www.nic.com/cgi-bin/whois.cgi?query=' . decode_ip($picrow[$j]['pic_user_ip']) . '" target="_blank">' . decode_ip($picrow[$j]['pic_user_ip']) .'</a><br />' : ''
				)
			);
		}
	}
Bitte nicht an den ganzen Template Variablen stören, ich habe quasi copy&paste aus dem Album Mod gemacht.

Template:

Code: Alles auswählen

<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
  <tr>
	<th class="thTop" height="25" align="center" colspan="{S_COLS}" nowrap="nowrap">{L_CATEGORY} :: {CAT_TITLE}</th>
  </tr>
  <!-- BEGIN no_pics -->
  <tr>
	<td class="row1" align="center" height="50"><span class="gen">{L_NO_PICS}</span></td>
  </tr>
  <!-- END no_pics -->
  <!-- BEGIN picrow -->
  <tr>
  <!-- BEGIN piccol -->
	<td align="center" width="{S_COL_WIDTH}" class="row1"><span class="genmed"><a href="{picrow.piccol.U_PIC}" {TARGET_BLANK}><img src="{picrow.piccol.CATEGORY_IMG}" border="0" alt="{picrow.piccol.DESC}" title="{picrow.piccol.DESC}" vspace="10" /></a><br />{picrow.piccol.APPROVAL}</span></td>
  <!-- END piccol -->
  </tr>
  <tr>
  <!-- BEGIN pic_detail -->
	<td class="row2"><span class="gensmall">
	{L_PIC_TITLE}: {picrow.pic_detail.TITLE}<br />
	{L_POSTER}: {picrow.pic_detail.POSTER}<br />
	{L_POSTED}: {picrow.pic_detail.TIME}<br />
	{L_VIEW}: {picrow.pic_detail.VIEW}<br />
	{picrow.pic_detail.RATING}
	{picrow.pic_detail.COMMENTS}
	{picrow.pic_detail.IP}
	{picrow.pic_detail.EDIT}  {picrow.pic_detail.DELETE}  {picrow.pic_detail.LOCK}  {picrow.pic_detail.MOVE}</span>
	</td>
  <!-- END pic_detail -->
  </tr>
  <!-- END picrow -->
  <tr>
	<td class="catBottom" colspan="{S_COLS}" align="center" height="28">
		<span class="gensmall">{L_SELECT_SORT_METHOD}:
		<select name="sort_method">
			<option {SORT_TIME} value='pic_time'>{L_TIME}</option>
			<option {SORT_PIC_TITLE} value='pic_title'>{L_PIC_TITLE}</option>
			<option {SORT_USERNAME} value='username'>{L_USERNAME}</option>
			<option {SORT_VIEW} value='pic_view_count'>{L_VIEW}</option>
			{SORT_RATING_OPTION}
			{SORT_COMMENTS_OPTION}
			{SORT_NEW_COMMENT_OPTION}
		</select>
		&nbsp;{L_ORDER}:
		<select name="sort_order">
			<option {SORT_ASC} value='ASC'>{L_ASC}</option>
			<option {SORT_DESC} value='DESC'>{L_DESC}</option>
		</select>
		&nbsp;<input type="submit" name="submit" value="{L_SORT}" class="liteoption" /></span>
	</td>
  </tr>
</table>
Auch hier ist noch jede Menge überflüssiges drin, kommt später raus. Wo ist mein Fehler ???

Verfasst: 25.05.2004 22:09
von holzmichl
*bump*