Thinking Through Profiles With Similar Content

Is Coranto not working properly for you? Here's where to ask for support help; for best results, follow these steps:
  • - Check your core/addon documentation for possible solutions
  • - Search these forums for similar problems that have already been solved
  • - If you're still stumped, check out THIS TOPIC, and post your question in this forum!!

Moderators: Spunkmeyer, Dale Ray, SrNupsen, Bluetooth, Jackanape

Thinking Through Profiles With Similar Content

Postby CSEnforcer » Mon Feb 12, 2007 4:35 am

Need some help thinking through the logic of this, and suggestions on how to implement.

The 'news' part of my site includes two options:
--"News" category allows all users to post news
--"Newsfw" category allows certain users to post featured news.

There are three news-related profiles in play on the front part of my site:

1) newstop: shows the most recent article posted in the "newsfw" category, along with a header image.
2) newstop2: shows the 2nd and 3rd most recent articles in "newsfw" with a different style (no header image)
3) newstop3: shows 8 headlines from both "news" and "newsfw" categories, after skipping the first three articles.

Obviously, skipping the top 3 articles doesn't insure that everything from both categories is included, or that certain "newsfw" articles aren't repeated.

So, how can I set up profile 'newstop3' so that:
1) it doesn't skip any articles from the "news" category; and
2) it pulls from both categories, but duplicate articles show in the other 'newstop' and 'newstop2' profiles (i.e. the first 3 articles in the "newsfw" category)

Any suggestions? I've been digging into different areas so much that this one has me brainlocked.
CSEnforcer
 
Posts: 12
Joined: Mon Jan 22, 2007 12:49 am

Re: Thinking Through Profiles With Similar Content

Postby Dale Ray » Mon Feb 12, 2007 7:21 am

CSEnforcer wrote:So, how can I set up profile 'newstop3' so that:
1) it doesn't skip any articles from the "news" category; and
2) it pulls from both categories, but duplicate articles show in the other 'newstop' and 'newstop2' profiles (i.e. the first 3 articles in the "newsfw" category)

If I am interpreting what you want correctly, after the first three items from the newsfs category are displayed you want the next 8 items from both news and newsfs and do not want to duplicate the first three items.

You need a counter.

Set up your profile to include both categories. If you are sure that there will be three items in the newsfs category you can set the profile to include 11 items.
Code: Select all
<PerlCode>
$shownews = 1;
if ($Category eq "newsfs" && $counter{$ProfileName} < 3) {
     $counter{$ProfileName}++;
     $shownews = 0;     
}
</PerlCode>
<If: Field: shownews>Put your item here</If>
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby CSEnforcer » Mon Feb 12, 2007 11:15 pm

Dale,

You definitely were able to translate what I'm looking for. The counter worked like a charm. It's always amazing to see what a little PerlCode can do.

As I update my site, I'm working on capturing a list of what all my profiles and styles are for. I'm hopeful that by doing that documentation I'll be able to either help answer some questions as they arise here, or help provide some helpful stuff for the wiki.

I've got at least one more challenge...of larger size... that I may throw out here to get your input on if you get time. Given some of the sites you do and your logical bent, I'm betting you'll have some ideas. I'll type that up when I can.

-Chad
CSEnforcer
 
Posts: 12
Joined: Mon Jan 22, 2007 12:49 am

Postby Dale Ray » Tue Feb 13, 2007 5:03 am

CSEnforcer wrote:Dale,

You definitely were able to translate what I'm looking for. The counter worked like a charm. It's always amazing to see what a little PerlCode can do.


Glad it worked (especially since I hadn't tested the code).
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana


Return to Troubleshooting

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron