OXID Community Forum

> International Forums > General > How to create a News Detail Page
Login
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Thread: How to create a News Detail Page


Reply
 
Thread Tools Display Modes
#Top   #1  
Old 04-20-2012, 11:51 AM
spierala spierala is offline
Member
Join Date: Nov 2011
Posts: 58
spierala is on a distinguished road
Default How to create a News Detail Page

Hallo all,
I added a lot of fields to the news in the backend.

Now the news should be shown in a list view and in a detail view.
The list view works in oxid per default (tpl/page/info/news.tpl).

but now i also need a template news_detail.tpl to show just the details of a single news...

Basically I wonder how I create the links that will open then the detail page and I have to send a parameter (the ID of the news to be shown).

Is there any further configuration needed?

Kind regards,
Florian
Reply With Quote
#Top   #2  
Old 04-20-2012, 02:57 PM
vanilla thunder's Avatar
vanilla thunder vanilla thunder is online now
Senior Member
Join Date: Nov 2010
Posts: 2,840
vanilla thunder is on a distinguished road
Default Re: How to create a News Detail Page

all you need is to create a new View Class which would display the one of your news, something like "newsdetails". For the beginning you can copy a existing View Class, e.g. "content" and edit/combine it with the news View to display a single news the way you want.

And you need a template for this view Class, which would display the details the way you want.

Just start with understanding the news view.
Reply With Quote
#Top   #3  
Old 04-24-2012, 03:56 PM
spierala spierala is offline
Member
Join Date: Nov 2011
Posts: 58
spierala is on a distinguished road
Default Re: How to create a News Detail Page

hey vanilla thunder,
thank you that worked quite well so far.

I´ve created /views/newsdetail.php
and
/out/mytemplate/tpl/page/info/newsdetail.tpl

In newsdetail.php I´ve put a function that does the db-request and returns an news object with all the properties that I need:
Code:
	
public function getNewsById($id){
    	$oDB = oxDb::getDb(true);
	$query = "SELECT * FROM oxnews WHERE oxid = '" .$id."'";
    	$row = $oDB->Execute( $query );
    	$news = new stdClass();
    	$news->titel = $row->fields["OXSHORTDESC"];
    	$news->datum = $row->fields["OXDATE"];
    	return $news;
}
and then I can use it in the tpl file like this:

[{assign var="nid" value=$smarty.get.nid}]
[{assign var="news" value=$oView->getNewsById($nid)}]
[{$news->titel}]

and finally the link to call the detail site looks like that:
[{assign var="nid" value=$oNews->oxnews__oxid->value}]
<a href="[{ $oViewConf->getSelfLink()|oxaddparams:"nid=$nid&amp;cl=newsde tail" }]">Weiterlesen</a>

Kind regards,
Florian
Reply With Quote
#Top   #4  
Old 04-25-2012, 10:40 AM
spierala spierala is offline
Member
Join Date: Nov 2011
Posts: 58
spierala is on a distinguished road
Default Re: How to create a News Detail Page

Hello,...
I found a little problem... the BreadCrumb does not work properly - contains just one link and it is wrong...

So far I have in newsdetail.php the same Breadcrumb function as in news.php:

Code:
public function getBreadCrumb()
    {
        $aPaths = array();
        $aPath  = array();

        $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_INFO_NEWS_TITLE', oxLang::getInstance()->getBaseLanguage(), false );
        $aPath['link']  = $this->getLink();

        $aPaths[] = $aPath;

        return $aPaths;
    }
}
Is there a "cool" way to fix the breadcrumb, otherwise I will just get the news id from the parameters and do db request again to put to correct links in the breadcrumb.

Many thx,
Florian
Reply With Quote
#Top   #5  
Old 04-25-2012, 04:45 PM
vanilla thunder's Avatar
vanilla thunder vanilla thunder is online now
Senior Member
Join Date: Nov 2010
Posts: 2,840
vanilla thunder is on a distinguished road
Default Re: How to create a News Detail Page

i guess the bredcrub's title is "nuigkeiten" and it points to the general news page, right?

the coolest way would be to fit
PHP Code:
$aPath['title'] = oxLang::getInstance()->translateString'PAGE_INFO_NEWS_TITLE'oxLang::getInstance()->getBaseLanguage(), false );
        
$aPath['link']  = $this->getLink(); 
to your needs, so it would display what ever you want to.

$aPath['title'] might be something like $news->titel
Reply With Quote
Reply

Bookmarks

Tags
create, news, page, template

« Previous Thread | Next Thread »
Thread Tools
Display Modes

Nicht Sichtbar
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't create a country ferclaverino Installation and configuration 10 04-18-2012 08:58 PM
Several pages for "news" section. (The locator-navigation for "news" section). v_h Developers 2 02-13-2012 07:27 AM
how to display 2 news items in start page workingprojectss Developers 2 07-06-2010 12:00 PM
How to edit product detail and catalog detail boongui Newbies 3 06-11-2010 04:24 PM
Product Detail Page LSobanski Product presentation 8 02-09-2010 11:55 AM

All times are GMT +2. The time now is 03:46 AM.