Du bist nicht angemeldet. Der Zugriff auf einige Boards wurde daher deaktiviert.

#1 04. März 2014 18:36

LUCKMAGAZIN
kennt CMS/ms
Ort: Nuthe-Urstromtal
Registriert: 23. Oktober 2010
Beiträge: 184
Webseite

Altes Thema neu aufgefrischt... Newsausgabe in 2 Spalten

Ich möchte das Thema Newsausgabe in 2 Spalten nochmal auffrischen...

Wie bekommt man das hin...
Möchte zum Beisspiel hier die Zusammenfassung auf der folgenden Seite in 2 Spalten machen.

sos-strassentiere.de

Wer kann helfen?


MfG Marcel

Offline

#2 05. März 2014 10:06

NaN
Moderator
Ort: Halle (Saale)
Registriert: 09. November 2010
Beiträge: 4.437

Re: Altes Thema neu aufgefrischt... Newsausgabe in 2 Spalten

Die einfachste Variante wäre, den DIVs mit der Klasse "NewsSummary" im Stylesheet folgende Eigenschaften zu geben:

.NewsSummary {
    ...
    width:45%;
    float:left;
}

Wenn Du dann noch darauf achtest, dass die NewsSummary-Divs die gleiche Höhe haben (z.B. height:330px) dann sieht das ganze auch etwas aufgeräumter aus.

Du könntest allerdings auch wirklich "Zeilen" mit jeweils zwei News-Artikeln erstellen. Dazu gibt es ein Smarty-Plugin split_row. Dort gibt man die Anzahl der Spalten an, und den Rest erledigt das Plugin. Könntest so also auch eine Tabelle draus machen. Das Plugin ist aber schon etwas älter. Hab es mal etwas aktualisiert:

<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/*
  Distributed under the terms of the BSD Licence:
  Copyright (c) 2007, Internet Brands, Inc (www.internetbrands.com)

  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are met:

      * Redistributions of source code must retain the above copyright notice, this list of
        conditions and the following disclaimer.
      * Redistributions in binary form must reproduce the above copyright notice,
        this list of conditions and the following disclaimer in the documentation and/or other
        materials provided with the distribution.
      * Neither the name of the Internet Brands nor the names of its contributors may be used
        to endorse or promote products derived from this software without specific prior
        written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**
 * Smarty {split}{/split} block plugin
 *
 * Type:     block function<br>
 * Name:     split<br>
 * Purpose:  loop structure that splits an array into rows to allow for column formatting
 * @param array
 * <pre>
 * Params:   count: number of columns
 *           from: source array
 *           name: smarty param to assign chunks to
 * </pre>
 * @author Kevin Sours (kevin.sours@internetbrands.com)
 *         Internet Brands (http://ibbydev.blogspot.com/)
 * @param string contents of the block
 * @param Smarty
 * @return string $content - smarty content is not modified.
 */

/*
  CHANGELOG
  2014-03-05: compatibility fixes for smarty 3 (georg busch - NaN)
*/

function smarty_block_split_row($params, $content, &$template, &$repeat)
{
	static $sanity = 0;
	if (!array_key_exists('from', $params)) {
		# Smarty API method trigger_error() is deprecated (NaN)
		#$template->trigger_error("split_row: missing 'from' parameter", E_USER_WARNING);
		$repeat = false;
		return;
	}

	//if the source var isn't set, quietly treat it as empty.
	if(is_null($params['from'])) {
		$repeat = false;
		return;
	}

	if (!is_array($params['from'])) {
		# Smarty API method trigger_error() is deprecated (NaN)
		#$template->trigger_error("split_row: 'from' parameter must be an array", E_USER_WARNING);
		$repeat = false;
	return;
	}

	if (!isset($params['item'])) {
		# Smarty API method trigger_error() is deprecated (NaN)
		#$template->trigger_error("split_row: missing 'item' parameter", E_USER_WARNING);
		$repeat = false;
		return;
	}

	$count = 2;
	if (isset($params['count'])) {
		$count = $params['count'];
	}

	$name = $params['item'];

	$indexName = "smarty.IB.split_row.$name.index";
	$index = $template->get_template_vars($indexName);
	if(!$index) {
		$index = 0;
	}
	$lastName = "smarty.IB.split_row.$name.last";

	$source = $params["from"];
	if(is_null($content)) {
		split_row_helper_doslice($template, $name, $source, $index, $count);
		$index++;
		$template->assign($indexName, $index);
	}
	else {
		if($index >= ceil(count($source)/$count)) {
			$template->clear_assign($indexName);
			$template->clear_assign($name);
		}
		else {
			split_row_helper_doslice($template, $name, $source, $index, $count);
			$index++;
			$template->assign($indexName, $index);
			$repeat = true;
		}

		if($sanity > 10) {
			$repeat = false;
		}
		$sanity++;

		return $content;
	}
}

function split_row_helper_doslice(&$template, $name, $source, $index, $columns) {
	$colsize = ceil(count($source)/$columns);
	$row = array();
	for($i = 0; $i< $columns; $i++) {
		$item = array_slice($source, ($i * $colsize) + $index, 1, false);
		$row = array_merge($row, $item);
	}
	$template->assign($name, $row);
}

?>

Bsp. (Auszug aus dem Standard News-Summary-Template):

{split_row count="2" from=$items item="itemsSplit"}

	<div class="row">

		{foreach from=$itemsSplit item=entry}

			<div class="NewsSummary">

				{if $entry->postdate}
					<div class="NewsSummaryPostdate">
						{$entry->postdate|cms_date_format}
					</div>
				{/if}

				...

			</div>

		{/foreach}

	</div>

{/split_row}

Module: GBFilePicker, AdvancedContent
Sicherheit: Beispiel .htaccess-Datei
CMSms 1.12 unter PHP 7:
cmsms-1.12.3.zip (inoffiziell - komplett inkl. Installer)
CMSms 1.12 unter PHP 8:
cmsms-1.12.4.zip (inoffiziell - komplett inkl. Installer)

Offline

#3 06. März 2014 17:20

LUCKMAGAZIN
kennt CMS/ms
Ort: Nuthe-Urstromtal
Registriert: 23. Oktober 2010
Beiträge: 184
Webseite

Re: Altes Thema neu aufgefrischt... Newsausgabe in 2 Spalten

Cool - Danke!

Beitrag geändert von LUCKMAGAZIN (06. März 2014 17:36)


MfG Marcel

Offline