WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Code Snippet: Display news items, anywhere
  • Print
Pages: 1 2 [3] 4 5 ... 21   Go Down

Author Topic: Code Snippet: Display news items, anywhere  (Read 372282 times)

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #50 on: December 06, 2005, 04:47:05 PM »
hi and thanks... ill try this tomorrow when i´ll get back to work

but why does the sorce look like that?? and you said "Doesn't look all to good to me"
can i change it, so it looks more "normal"?
Logged

pcwacht

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #51 on: December 06, 2005, 07:12:14 PM »
all the " are addslashed, ie, there are too many \ (backslashes)
<img height=\"73\" hspace=\"5\" should be
<img height="73" hspace="5" in html

John
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #52 on: December 07, 2005, 03:02:51 PM »
hi John

please could you explain what you mean by this

"PS, The pictures for groups needs to be upoloaded first!
admin -> pages -> the page with news -> add groups (or modify group)-> image!!!"

When i have set pictures in, yet, i´ve just been putting them next to the text in both short and long text!
Logged

pcwacht

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #53 on: December 07, 2005, 04:52:49 PM »
This snippet will only show the group pictures, not the wysiyg added pictures.
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #54 on: December 08, 2005, 10:53:55 AM »
hi again..

the group picture is´nt working, i can´t choose any picture, without getting an error!

but it is the wysiwig picture i wanted to show, but i thats impossible :|

but thanks for your help

Logged

mangione

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #55 on: January 09, 2006, 03:53:54 PM »
HI, i think you mean, that you wanna show the wysiwyg images also in the function where you get the last items and display it anywhere. I always had the problem, that the path from my images was wrong.

The plan was, to open the last newsitem in the "long" version and display the older news on the bottom. I used the following code:

--------- insert in a code page ----------

// Specify the Group(id) you want to read the news from or 0 for all groups
$group = 0;       

// Specify number of newsitems                       
$limit=10;

// Specify read more text
$readmore = "Weiterlesen";       

// Specify Older news text
$oldernews = "Older news";       

// Query for all groups ;)
if ($group<1 ) {
  $query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE active = 1 ORDER BY position DESC LIMIT 0, 10;";
}




// No changes needed here, maybe for output!

global $database;

$result = $database->query($query);
$total = $result->numRows();       // how many items are there?

if ($total>1) {                                // x
  $data = $result->fetchRow() ;    // get news item
$long=stripslashes($data['long']); //clear up the images path
  echo '<table width=100%>';
  echo '<tr><td width=100%><h1>'.$data['title'].'</h1></td></tr>';
echo '<tr><td>'.$long.'</td></tr>'; //view the long-version of the news
  echo '<tr><td></td><td></td></tr>';
  echo '</table>';
}

   // Specify the Group(id) you want to read the news from or 0 for all groups
$group = 0;       

// Specify number of newsitems                       
$limit=0;

// Specify read more text
$readmore = "Artikel lesen";       

// Specify Older news text
$oldernews = "weitere Einträge";       

// Query for obtaining stuff from a group
$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group and active = 1 ORDER BY position DESC LIMIT 0, 10;";

// Query for all groups ;)
if ($group<1 ) {
  $query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE active = 1 ORDER BY position DESC LIMIT 1, 10;";
}

// No changes needed here, maybe for output!

global $database;

$result = $database->query($query);
$total = $result->numRows();       // how many items are there?

if ($total>1) {                                // at least 2 needed for 2 news items
  $data2 = $result->fetchRow() ;    // get left item
  $data3 = $result->fetchRow() ;    // get left item
  $data4 = $result->fetchRow() ;    // get left item
  $data5 = $result->fetchRow() ;    // get left item
  $data6 = $result->fetchRow() ;    // get left item
  $data7 = $result->fetchRow() ;    // get left item
  $data8 = $result->fetchRow() ;    // get left item
  $data9 = $result->fetchRow() ;    // get left item
  $data10 = $result->fetchRow() ;    // get left item
  echo '<table class="newsoverview" width=100%>';
echo '<tr><td width="100%"><b>weitere News</b></td></tr>';
  echo '<tr><td width=100%><li><a href='.WB_URL.PAGES_DIREC TORY.$data2['link'].PAGE_EXTENSION.'>'.$data2['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href='.WB_URL.PAGES_DIREC TORY.$data3['link'].PAGE_EXTENSION.'>'.$data3['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data4['link'].PAGE_EXTENSION.'">'.$data4['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data5['link'].PAGE_EXTENSION.'">'.$data5['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data6['link'].PAGE_EXTENSION.'">'.$data6['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data7['link'].PAGE_EXTENSION.'">'.$data7['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data8['link'].PAGE_EXTENSION.'">'.$data8['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data9['link'].PAGE_EXTENSION.'">'.$data9['title'].'</a></td></tr>';
  echo '<tr><td width=100%><li><a href="'.WB_URL.PAGES_DIREC TORY.$data10['link'].PAGE_EXTENSION.'">'.$data10['title'].'</a></td></tr>';
  echo '</table>';
}
Logged

artwebbo

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #56 on: March 24, 2006, 12:19:56 PM »
Hi,

everything works perfect but I'm not a php coder and I have a little problem about how to impelement this...

I want to display news from mostly every news groups without one group on the other subpage.
How to put it in code?


thanks for helping,
Ewa

Logged

Offline gokcer

  • Posts: 94
Get Some Settings
« Reply #57 on: May 24, 2006, 07:28:22 PM »
I've modified this code for my needs. You can specify the columns, last post limit, "active or not" from that pages "news settings" in the administration panel of wb without changing anything in the code. You must only specify the page_id of news page. This code is available with a "modified a lot" version of wb :). Some of the variables may not be available with standart (not much modified) versions. But maybe you can make available by modifying or deleting some codes. For example my link creation codes are different so I use only ".$link." in the "href"s. But the standart link code is ".WB_URL.'/pages/'.$link.PAGE_EXTENSION."

Place this code in your template file where you want to display the latest news:

Code: [Select]



<table width="100%" height="0%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
<?php 
define
(&#39;yenisatir&#39;, &#39;</tr><tr>&#39;); // yenisatir means new row
global $database;
$get_page = 4; // insert page_id here

$query_settings = $database->query("SELECT posts_per_page FROM ".TABLE_PREFIX."mod_news_settings WHERE page_id=$get_page");
$fetch_settings = $query_settings->fetchRow();
$latest = $fetch_settings[&#39;posts_per_page&#39;]; // this calls the standard wb&#39;s post per page setting. So you can change latest news quantity by only changing your post per page setting. So, the quantities of post per page and latest news will be same.

$query = "SELECT ".TABLE_PREFIX."mod_news_posts.post_id,".TABLE_PREFIX."mod_news_posts.short,".TABLE_PREFIX."mod_news_posts.title,".TABLE_PREFIX."mod_news_posts.link,".TABLE_PREFIX."mod_news_settings.num_cols FROM ".TABLE_PREFIX."mod_news_posts,".TABLE_PREFIX."mod_news_settings WHERE ".TABLE_PREFIX."mod_news_posts.page_id=$get_page AND ".TABLE_PREFIX."mod_news_posts.active=1 AND ".TABLE_PREFIX."mod_news_settings.page_id=$get_page ORDER BY position DESC LIMIT 0, $latest;";
// If you want to make different the quantities of post per page and latest news, replace "$latest" with a number above to specify the latest news quantity

$error = mysql_error();
if (!
$result = mysql_query($query)) {
print 
"$error";
exit;
}

$counter = 0;
while(
$data = mysql_fetch_object($result))
{
$title = $data->title;
$short = $data->short;
$id = $data->post_id;
$link = $data->link;
$num_cols = $data->num_cols; 
echo stripslashes(&#39;<td class="haber" align="left" valign="top"><div style="padding-bottom: 1px; font-weight: bold;" ><b><a href="&#39;.$link.&#39;">&#39;.$title.&#39;</a></b></div>&#39;.$short.&#39;</td>&#39;); // If you didn&#39;t modified your WB to work with "safe mode on" (in other words if you are using default WB), replace .link. with .WB_URL.&#39;/pages/&#39;.$link.PAGE_EXTENSION.
$counter = $counter+1;
if($counter == $num_cols) // I&#39;ve added a column setting in my news module similiar to gallery module&#39;s column setting. I can specify my column quantity from news&#39; settings and latest news gets the number from there. If you didn&#39;t add (in other words if you are using default WB) replace $num_cols with a number to specify a column quantity
{
echo yenisatir;
$counter = 0;
}
}
?>

  </tr></table>




good luck...
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #58 on: October 09, 2006, 02:42:49 PM »
hi... i know this is a long time, since this subject was in use!

but i just can´t get it to work right!

i use this code.. in my template:

___________________ _______________
Code: [Select]
<?php
global $database;
$query = "SELECT post_id,title,group_id,link FROM ".TABLE_PREFIX."mod_news_posts ORDER BY position DESC LIMIT 0, 5;";

$error = mysql_error();
if (!
$result = mysql_query($query)) {
print 
"$error";
exit;
}

while(
$data = mysql_fetch_object($result)){
$title = $data->title;
$id = $data->post_id;
$link = $data->link;
echo &
#39;<font class="nyttlink"><a href="&#39;.WB_URL.$link.PAGE_EXTENSION.&#39;">&#39;.$title.&#39;</font><br /><br /></a>&#39;;
}
?>
___________________ _________________

it works.. fine, until... when i press on the news... displayed.. it just says this:

[an error occurred while processing this directive] The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page  about the error. [an error occurred while processing this directive]

anyone know why  :?
« Last Edit: October 09, 2006, 04:30:59 PM by babsy »
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #59 on: October 09, 2006, 07:05:04 PM »
I just tested the exact script, works fine here.

Have a look into my Templates "Snakeskin", Metalslabs" and "Molten Lava", they have this functionality implemented.

Maybe as a test, install them and try if they do work, just to make shure, that it's not a server issue.

Also try with a simple testpost (simple name like "test") to see if this works.

cheers

Klaus
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #60 on: October 09, 2006, 08:55:12 PM »
thx... so far so good!!

but, i think i have another problems, but its not in the code i think!

because.... check it out http://klaknav.sudurras.com

now the code works... and the news.... exept when i press on read more...

the top header of my template goes away  :?

really weird!... 
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #61 on: October 09, 2006, 09:08:44 PM »
but that is the template ... cause the URL:

Quote
http://klaknav.sudurras.com/pages/templates/round/top1_2.jpg

can not work.

Rework your template (have a look at the tutorial in the WIKI for the template path).

cheers

Klaus
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #62 on: October 09, 2006, 09:10:18 PM »
thanks..... i will... :-)

UPDATE:... works like a charm now!  :-D so thx again!!

but i could´nt find the exact image path in the template tutorial!??
but i just downoaded another template and took it from there, (don´t know why i didn´t think of that right away  :| )

so if anyone else (well a newbie i guess  :-D) is looking, this was it:

<td><img src="<?php echo TEMPLATE_DIR; ?>/top1_2.jpg" alt="" height="30" width="700" border="0" /></td>

so thanks again...
now everythink is working.. so far so good..

actually i would love to build some template for wb, now i think i can start on that  :wink:
« Last Edit: October 09, 2006, 10:11:24 PM by babsy »
Logged

Offline Bramus

  • Posts: 608
  • Gender: Male
    • BRAMUS Internet Services
Re: Code Snippet: Display news items, anywhere
« Reply #63 on: December 20, 2006, 09:05:50 AM »
Some one made me this piece of code also some time ago. Maybe it is usefull for anyone here. I have translated some things into dutch, but to edit it, that should be real easy. You can enter the max of news items to show and from what group or just all the news groups.

As i said IT IS NOT MADE BY ME! I respect this work and just want to share it with you. Some one posted it already some time for me, can't remember if it was by mail or here.

Example --> www.cavaliershelden.nl

Code: [Select]
// Specify the Group(id) you want to read the news from or 0 for all groups
$group = 2;       

// Specify number of newsitems                       
$limit=4;

// Specify read more text
$readmore = "Lees Verder";       

// Specify Older news text
$oldernews = "Oude items";       

// Query for obtaining stuff from a group
$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group and active = 1 ORDER BY position DESC LIMIT 0, 10;";

// Query for all groups ;)
if ($group<1 ) {
  $query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE active = 1 ORDER BY position DESC LIMIT 0, 10;";
}

// No changes needed here, maybe for output!

global $database;

$result = $database->query($query);
$total = $result->numRows();       // how many items are there?

if ($total>1) {                                // at least 2 needed for 2 news items
  $data = $result->fetchRow() ;    // get left item
  $data2 = $result->fetchRow() ;  // get right item
  echo '<table width=100% border=0>';
  echo '<tr><td width=50%><b>'.$data['title'].'</b></td><td></td></tr>';
  echo '<tr><td>'.$data['content_short'].'</td><td></td></tr>';
  echo '<tr><td><a href="'.WB_URL.PAGES_DIRECTORY.$data['link'].PAGE_EXTENSION.'">'.$readmore.'</a></td><td></td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td></td><td width=50%><b>'.$data2['title'].'</b></td></tr>';
  echo '<tr><td></td><td>'.$data2['content_short'].'</td></tr>';
  echo '<tr><td></td><td><a href="'.WB_URL.PAGES_DIRECTORY.$data2['link'].PAGE_EXTENSION.'">'.$readmore.'</a></td></tr>';
  echo '</table>';
}

// Next show the rest
if ($total>2) {                                // are there any left?
echo '<br><br><table><tr><td colspan=2><b>'.$oldernews.'</b></td></tr>';
echo '<tr><td>Datum</td><td>Onderwerp</td></tr>';
while ($data = $result->fetchRow()) {
  echo '<tr><td>'.strftime( "%d-%m-%Y",$data['posted_when']).'</td>';
  echo '<td><a href="'.WB_URL.PAGES_DIRECTORY.$data['link'].PAGE_EXTENSION.'">'.$data['title'].'</a></td></tr>';
}
echo '</table>';
}

This can be used in a CODE section on a page.
« Last Edit: December 20, 2006, 09:14:03 AM by Bramus »
Logged
BRAMUS Internet Services

beeswax

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #64 on: December 27, 2006, 02:16:26 PM »
I'm really new to WB, and I've tried to follow this thread and implement it, but so far with no luck.
Earlier in this thread sowmone refers to the template Wiki, where is it? I don't know how to insert code into a template (I tried, but didn't get very far), will I find this on the Wiki?
When it comes to code(ing) I'm very, very, very noob.
beeswax
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #65 on: December 27, 2006, 03:12:54 PM »
the wiki can be found here (link goes to the english page): http://projects.WebsiteBaker.org/websitebaker2/wiki/Docs-EN

To get this code going, create a page of type "code" and paste the code into this page. You will need to have a page of type "news", with some news-articles, otherwise this code has nothing to display.

cheers

Klaus
Logged

beeswax

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #66 on: January 02, 2007, 06:53:25 AM »
Happy New Year.
I've pasted the code into a Code page, and it works, but what I'd like to do is to have the News "Headlines" in the sidebar, and when they click on "Read More" the detailed news opens in the Main page. I've looked at modify_settings.php (if that's where I should be looking) in the News module but I'm afraid that I can't make too much sense of it.
At the moment I'm working on the site "locally" so I can't give anyone a preview.
thanks, in advance
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #67 on: January 02, 2007, 09:31:57 AM »
have a look at the templates "Gray Snake" and "Metal Slabs" (the links are temporary links to the add-on pages! They will change!)


They have included, what you want to achieve.

cheers

Klaus
Logged

beeswax

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #68 on: January 03, 2007, 03:35:51 PM »
I've downloaded MetalSlabs and installed it, and the News sections work how I want them to. I've gone into page settings and written down the settings as they appear in MetalSlabs so that I can change the template to Andreas02 and make sure the page settings are the same (the only difference being that instead of "Left Column", Andreas02 has "Sidebar"), and that's when it all falls apart for me. I really am at a loss as to what to do next :|
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #69 on: January 03, 2007, 04:55:13 PM »
Have a look at the template sourcecode. There you can see, how it is implemented. You then take the script part and paste it into the template you want to use it ...

In the Andreas02 Template the code comes in like this here:

Code: [Select]
<div id="sidelink">
</div>
</p>
<-- Login Box start -->
<form name="login" action="http://w007be2b.dd15712.kasserver.com/account/login.php" method="post" class="login_table">
<h2>Login</h2>
Username:
<input type="text" name="username" style="text-transform: lowercase;" />

Password:
<input type="password" name="password" />
<input type="submit" name="submit" value="Login" style="margin-top: 3px; text-transform: uppercase;" />
<a href="http://w007be2b.dd15712.kasserver.com/account/forgot.php">Forgot Details?</a>
</form>
<-- Login Box End -->

<--News Box start -->

<?php
// Specify the Group(id) you want to read the news from or 0 for all groups
$group = 0;       

// Specify number of newsitems                       
$limit=10;

// Specify read more text
$readmore = "Read more";       

// Specify news text
$news = "Latest News";       

// Query for obtaining stuff from a group
$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group and active = 1 ORDER BY position DESC LIMIT 0, 10;";

// Query for all groups ;)
if ($group<1 ) {
  
$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE active = 1 ORDER BY position DESC LIMIT 0, 10;";
}

// No changes needed here, maybe for output!

global $database;

$result = $database->query($query);
$total = $result->numRows();      // how many items are there?

if ($total>1) {                   // at least 2 needed for 2 news items
  
$data = $result->fetchRow() ;   // get left item
  
$data2 = $result->fetchRow() ;  // get right item
  
echo &#39;<span style="font-size: 14px; color: #fff; display: block; font-weight: bold; border-bottom: 1px solid;">&#39;.$news.&#39;</span>&#39;;
  
echo &#39;<p style="border-bottom: 1px solid #000; font-weight: bold; font-size: 12px; color: #fff;">&#39;.$data[&#39;title&#39;].&#39;</p><p style="font-size: 12px; text-align: justify; color: #fff;">&#39;.$data[&#39;content_short&#39;].&#39;<br /><a href="&#39;.WB_URL.PAGES_DIRECTORY.$data[&#39;link&#39;].PAGE_EXTENSION.&#39;">&#39;.$readmore.&#39;</a></p>&#39;;
  
echo &#39;<p style="border-bottom: 1px solid #000; font-weight: bold; font-size: 12px; color: #fff;">&#39;.$data2[&#39;title&#39;].&#39;</p><p style="font-size: 12px; text-align: justify; color: #fff;">&#39;.$data2[&#39;content_short&#39;].&#39;<br /><a href="&#39;.WB_URL.PAGES_DIRECTORY.$data2[&#39;link&#39;].PAGE_EXTENSION.&#39;">&#39;.$readmore.&#39;</a></p>&#39;;
}
else {
  echo &
#39;<span style="font-size: 14px; display: block; font-weight: bold; border-bottom: 1px solid;">No News yet ...</span>&#39;;
}
?>

<-- News Box ends -->
</div>

Then you just change the styles to what you need (all the styles used in this script are direct formatting).

cheers

Klaus
Logged

Offline mikejd

  • Posts: 251
Re: Code Snippet: Display news items, anywhere
« Reply #70 on: February 18, 2007, 03:03:40 PM »
I have been trying to modify this code to use with the events module, inserted into a Code section.

The code I'm using is :

global $database;
$query = "SELECT date,event_desc FROM ".TABLE_PREFIX."2006mod_event_dates ORDER BY date DESC LIMIT 0, 5;";

$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}

while($data = mysql_fetch_object($result)){
$title = $data->event_desc;

echo '<p><a href="">'.$title.'</a></p>';
}

and I get an error message :

Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /home/fhlinux190/d/deveron-arts.com/user/htdocs/wb/modules/code/view.php(30) : eval()'d code on line 13

Is this code OK? or how can I change it to work?

Regards,
Mike Davies
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #71 on: February 18, 2007, 03:43:11 PM »
I think you just forgot 2 closing semicolons behind the brackets: "};" but I might be wrong there since I am no real coder.

cheers

Klaus
Logged

doc

  • Guest
Anynews snippet module v0.10
« Reply #72 on: February 18, 2007, 03:46:13 PM »
Hello,

Matthias (ruebenwurzel) asked me, if I could create a snippet module of the display news items anywhere code posted in that thread. Well here my first version.

Installation
 - download the attached zip file to your computer
 - log into the backend of WB and install the module as usual

Using the snippet function
Once the module is installed, it can be invoked either from the index.php file of your template or from any code module section.
Code: [Select]
<?php display_news_items(); ?>
For a more customised output, you can pass over serveral parameters to the function explained below.
Code: [Select]
<?php display_news_items($group_id, $max_news_items, $max_news_length, 
$header_text, $readmore_text, $no_news_text); ?>


Optional parameters (default values stated as well):
group_id... group from which you want to read news from (default:= 0 for all groups)
max_news_items... max. number of news shown (default:= 10, values>10 will be lowerd to 10)
max_news_length... max. length of the short news text shown (default:=150)
header_text...  heading text shown (default:="Latest news")
readmore_text...  text displayed for readmore link (default:=read more)
no_news_text...  text shown if no news available (default:="no news avaialbe yet...")

Have fun.
Regards Christian

Removed file. Any news is now available in the section Additional Functions on addons repository
« Last Edit: February 20, 2007, 09:08:54 PM by doc »
Logged

Offline YeShakka

  • Posts: 144
Re: Code Snippet: Display news items, anywhere
« Reply #73 on: February 19, 2007, 12:42:27 PM »
Thank you for that. Nice contribution.

But shouldn't this go into "completed code snippets"?
Logged

Offline mikejd

  • Posts: 251
Re: Code Snippet: Display news items, anywhere
« Reply #74 on: February 19, 2007, 03:21:01 PM »
kweitzel - I tried adding the ;s but it didn't work. i think they were in the right place. It stopped all the page after the code block from loading.

Thanks anyway.
Mike
Logged

  • Print
Pages: 1 2 [3] 4 5 ... 21   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Code Snippet: Display news items, anywhere
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2