Welcome, Guest. Please login or register.
Did you miss your activation email?
February 13, 2012, 03:27:38 AM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
149700 Posts in 21103 Topics by 7538 Members
Latest Member: ionline
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: news items with pre-defined sections in between - solved -  (Read 818 times)
snark
Guest
« on: September 07, 2010, 11:14:48 AM »

I am trying the following:

In a list of newsitems I need to place an ad that is always between the 4th and the 5th newsitem

what I did is I added a field named "position" in the modify_post and save_post files

Code:
<tr>
<td>
Positie:</td>
<td width="80%">
<input type="text" name="position" value="<?php echo (htmlspecialchars($fetch_content['position'])); ?>" style="width: 98%;" maxlength="255" />
</td>
</tr>

so far so good, I can easily change the position of the newsitems

now in the view i want to add something that will include a section from another page when position = 4

in the view i found
Code:
$short = ($post['content_short']);

if this can be changed to something like
Code:
$shortmessage = ($post['content_short']);
$advertisement = include-section-x;

if($position == 4) {

$short = $shortmessage.$advertisement;
} else {

$short = $shortmessage;
}

I guess this can come in handy for more people but I can not really figure out how to get it done




« Last Edit: October 05, 2010, 09:58:09 PM by snoork » Logged
snark
Guest
« Reply #1 on: September 07, 2010, 09:54:24 PM »

if anyone knows how to get the $position from the databse into the view.php I would be very greatful
Logged
Ruud
Board member
WebsiteBaker Org e.V.

Offline Offline

Posts: 2094



WWW
« Reply #2 on: September 07, 2010, 10:21:20 PM »

I am sure I could help... As soon as I would have a clue what you are doing  rolleyes

If you want to add something on the 4th item displayed, you don't need to add positions in the database. They would need to change after every insert of a new news-item.

In the view.php (around line 216) there is the loop that will create the output.
Add a counter in there, and when the counter is "4" add your advert.

Outside the while-loop define your counter
$counter 0;
In the loop you add something like
$counter++; 
if (
$counter == 4) { $short .= $advertisement  }

Hope this helps..
Logged

Professional WebsiteBaker Developer
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #3 on: September 08, 2010, 11:45:13 AM »

make a droplet, droplets can alter output before it is sended to the client!!!!

The droplet should do the following
1 - scan for postspecific tekst, default it could be '<tr class="post_top">'
2 - if fourth hit is found -
- 1 fetch needed section
- 2 prepare for output
- 3 insert in your output

This way nothing needs to be altered on core files.

Have fun,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
snark
Guest
« Reply #4 on: September 08, 2010, 01:18:14 PM »

I am sure I could help... As soon as I would have a clue what you are doing  rolleyes


make sure advertisings on a newspage remain on the same positions while the news always gets updated ...

thanks to you both, I will try the offered suggestions tomorrow, I will keep everone informed

Logged
snark
Guest
« Reply #5 on: October 05, 2010, 11:46:08 AM »

finally found time to work on this again,

I managed to get it working, it places some text underneath the 4th news-item with the code:
Code:
if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";

// Replace [wblink--PAGE_ID--] with real link

if ($counter == 4)

{
$short = ($post['content_short']).'some text';
$wb->preprocess($short); 

}

else
{
$short = ($post['content_short']);
$wb->preprocess($short);
}

but I want a newsitem from another newspage to be inserted, I made a group in which the item that should turn up is present,

I did
Code:
if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";

// Replace [wblink--PAGE_ID--] with real link
$aap = 'displayNewsItems(5, 200, 200, 8, 'auto', true, '<p><a><img>', false, 1, 1, 0)';
if ($counter == 4)

{
$short = ($post['content_short']).$aap;
$wb->preprocess($short); 

}

else
{
$short = ($post['content_short']);
$wb->preprocess($short);
}

where the normal newspage should inherit messages from the other newspage which are member of group 5

I guess it is not allowed to add anynews code like I did...

can anyone tell me how I can get it done?

Logged
snark
Guest
« Reply #6 on: October 05, 2010, 09:57:41 PM »

on goes the monologue...

solved,

I created several new tables in the news_settings tables

named insert_inbetween_po st_1  etc

in the view.php I placed the counter as Ruud described, combined with some if  /  else if statements

so that if the post count is for instance '2', the &short is $short.$insert_inbetween_post_1

I made corresponding fields in the settings.php so I can use those fields to insert almost anything, I used [showsection]] to insert pages in between the news items

many would probably not understand this but I do not know how to explain it better,
Logged
Ruud
Board member
WebsiteBaker Org e.V.

Offline Offline

Posts: 2094



WWW
« Reply #7 on: October 05, 2010, 10:35:40 PM »

on goes the monologue...

Sorry for that. Just know that you have at least one listener/reader.
As soon as I think I can help I will do so.

solved,

Great news..
Show us the results when it is live  smiley
Logged

Professional WebsiteBaker Developer
snark
Guest
« Reply #8 on: October 06, 2010, 06:12:12 AM »

Hey ruud, nice to hear that my crazy ideas have got some interest, I am not sure if everyone understands these otions but i am sure it will make the module better.

I have added Some real cool things to bakery lately, one of them is the possibillity to choose the functions for THE modify page, i will add this to the news page too

Even better, i received pcwacht's progress of his new newsmodule, I am putting in All my ideas at THE moment and Will also include this funcionallity.

I guess pcwacht will expand it further and i light contact you aboutaleb Some things. Enen i have a somewhat woeling version i will notify you.
Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #9 on: October 06, 2010, 10:01:31 AM »

@Snoork,

Since the add insertion is probably a one time thing I would have go with the droplet idea as described up.
I don't think that insertion between items should be a standard it is better not to include it in a module but use 'case-needed-php'.
Remember that any droplet can modify the output right before it is sended to the client. There are hardly any examples for this, but it is real easy to do.

Still looking to your ideas to make them in my module as well.

My module is somewhat on hold due to several reasons,
1 - developers are busy reworking the logic in modules due to security isseus as I understand it - am waiting for these
2 - received a new hip, operation went well, am slowly revalidating, can't sit for a long time behind my pc at the moment, am helping my sellf with a notebook

I need this module as well for PCWacht.nl and ICTWacht.nl so these are on ice as well Wink

In the meantime I am thinking on stuff to put in the new articles module , a kinda news module, wich will give better and broader use for it. From a simple news page to a more complex item based page with corresponding detailpage.

Have fun,
John 
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
snark
Guest
« Reply #10 on: October 06, 2010, 12:48:48 PM »

@Snoork,

Still looking to your ideas to make them in my module as well.


I think you have received a downloadlink from me
Logged
snark
Guest
« Reply #11 on: October 06, 2010, 02:47:01 PM »

is there a way to count the complete '$setting_post_loop'

what I now did was count the '$short = ($post['content_short'])'

but that makes my insertions appear undernearth the [TITLE] ...

Logged
Argos
Moderator
**
Offline Offline

Posts: 2084


WWW
« Reply #12 on: October 07, 2010, 05:36:53 PM »

Hey, this sounds like a great idea, especially for commercial sites. I hope a droplet or other handy thingy will come out of this!  grin
Logged

Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase: http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #13 on: October 07, 2010, 09:06:08 PM »

ok

My approach is allways to leave modules etc alone since a tiny update might break someones hard work
I love droplets and template codeing

There are different sane ways to reach the wanted output
One is to put extra code in the template which intercepts the news-list output and transfer generating output to own code
Put this in the template wich shows the news items in the place of the regular page_content(); call
Code:
<?php 
// Should we show list or ... ?
if(!defined('POST_ID') OR !is_numeric(POST_ID)) {   // Show list
  // Copy majort part from /news/view.php to here and alter the output wich is needed
} else {
  
// Let modeul news take ove rsince there is a post we want to see
  
page_content();
}

The other is to create a droplet wich scans the output and alter it the way it is needed.
The steps would be:
create a droplet, make sure the droplet is fired on the news page
Any droplet has acces to the output prior to sending it to the client thus is it capable of altering the ouyput
It should do something like:
1 scan output variable for start of list
2 scan for start of item, and increase a counter
3 if counter is 4 reset counter and insert needed html into output variable
4 are there more itmes, if so goto 2

Where it should fetch the html for insertion etc depends on the wishes

Since Snoork like to replace the view.php I would recommond him to go with the first oiption wich is actually simular but shorter thus better under control
I would go for the droplet method since I like these fancy specific-job-crafted-codes

The droplet method allso will give me a basic startpoint for something simular for another job Wink

Anyways, Have fun.
John
« Last Edit: October 07, 2010, 09:41:51 PM by Argos » Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
snark
Guest
« Reply #14 on: October 07, 2010, 10:52:05 PM »

On one hand i agreement on à droplet being the best, if anyone creates such à droplet i think lost of people Will find use for it. On the other hand it would be Nice if THE option would be availeble in the settings.php ... Als i think creative mines can do all kinds of things with it.

F.i. Give the first item à different backgroundcolor, or let THE first 4 items apear in 100%width and THE rest in 2 columns .... You could start your newspaper with this option taking  care of à Nice layout.
Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #15 on: October 08, 2010, 10:00:33 AM »

I agree, an option for giving the first x numbers of items a different layout is a good one to incorporate in a module.
Like making the first 3 at width 100 and the rest at two tables for examples,
or giving the first ones the short content and the rest not or... way too many options, will add it to my articles module wishlist

@Snoork, I can help you with the droplet, pm or mail me the details on what it is you want Wink and I'll start coding.

John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
snark
Guest
« Reply #16 on: October 09, 2010, 09:19:02 AM »

Great to see that my crazy ideas are turning into something useful. It would indeed be great to have something like pcwacht is suggesting.

Also take à look at nu.nl where all subject have à first item with photo and description and the rest only headlines.

At these times I really wish I was à coder ....
Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #17 on: October 13, 2010, 12:39:27 PM »

Snoork:
Maybe you missed the question?

Quote
@Snoork, I can help you with the droplet, pm or mail me the details on what it is you want  and I'll start coding

Need to lknow where the adds are for example... Wink
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!