1 of 2
1
Calendar template doesn’t limit results when passed a category ID
Posted: 03 March 2006 01:38 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  12-21-2005

I’m having difficulty getting a template with the {exp:weblog:calendar} tag to filter itself based on a category ID passed in the URL. For example:

I have a template set up to show all entries contained in the calendar weblog in a calendar. When I pass a it a category that I want it to limit the displayed data to, it still shows all the entries.

http://www.my-site.com/index.php?/calendar/      <-  Main Calendar Page, shows all entries regardless of category
http://www.my-site.com/index.php?/calendar/C8  <-  Doesn’t limit the results to the category with the ID of 8. In fact, filtering it by

categories like this doesn’t work, but it does in a template that doesn’t have the {exp:weblog:calendar} in it does.

Did I say that clearly enough? Any help would be greatly appreciated.

 Signature 

David Hemphill - freelancer // blog

Profile
 
 
Posted: 03 March 2006 07:42 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  25625
Joined  05-20-2002

Just to test- if you hard code the category as a parameter in the tag does it limit it as expected?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 03 March 2006 07:44 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  12-21-2005

Yes it does.

 Signature 

David Hemphill - freelancer // blog

Profile
 
 
Posted: 03 March 2006 07:45 PM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  25625
Joined  05-20-2002

Hm- well, let me go stick the calendar tag on a test template and check it out.  What version/build of EE are you on?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 03 March 2006 07:48 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  12-21-2005

My version is 1.4.0

 Signature 

David Hemphill - freelancer // blog

Profile
 
 
Posted: 03 March 2006 08:28 PM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  25625
Joined  05-20-2002

OK- I THINK I understand what you want and why it isn’t working.  You want the calendar day links to be handled dynamically- like the entries retrieved by the weblog tag are by default.  However, the calendar isn’t set up to be dynamic in quite that same way (which makes sense under typical use).

What you could try is snagging the category segment out of the url and using php to echo it out as a parameter.  Or hack it- it doesn’t look hard (give a yell if you want me to poke at it).  And either way, you might want to put in a feature request for the ability to do this- I can see how it would be handy to have the option.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 03 March 2006 08:39 PM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  12-21-2005

I thought of the URL segment thing. But that would only grab the “C8” (if that was the category I wanted) and not just the “8” part, correct? How can I grab the 8 out of the URL so I can echo it in the tag?

 Signature 

David Hemphill - freelancer // blog

Profile
 
 
Posted: 03 March 2006 08:50 PM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  25625
Joined  05-20-2002

You can use a little php- in your template prefs, make sure you have php turned ‘on’ for the template and parsing set to ‘input’- then try:

<?php
$c_id
= substr('{segment_3}', 1);
?>

{exp
:weblog:calendar category="<?php echo $c_id; ?>" switch="calendarToday|calendarCell"}

You’ll have to be a little careful- because this will screw up if you don’t have anything in segment 3.  You could add in some more checks- maybe define the whole parameter- stuff like that- if you are worried about hitting the template without the url structure you’re expecting.  But basically- that’s the idea.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 03 March 2006 09:16 PM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  12-21-2005

Awesome. Worked like a charm. I’m surprised I’m the only person who has needed this feature. Thanks for your help.

 Signature 

David Hemphill - freelancer // blog

Profile
 
 
Posted: 26 April 2006 10:44 AM   [ Ignore ]   [ # 9 ]  
Lab Assistant
RankRank
Total Posts:  242
Joined  02-02-2004

TO: David Hemphill
RE: You’re Not Alone

I’m getting my events calendar operational too.

Could you provide the code for your template, as it is now that it works properly?

Regards…..

Profile
 
 
Posted: 26 April 2006 03:26 PM   [ Ignore ]   [ # 10 ]  
Lab Assistant
RankRank
Total Posts:  242
Joined  02-02-2004

TO: rob1
RE: What About….

...ALL Categories?

Using your code (see example above), would not just those categories requested appear?

If no category has been set, or no category specified, nothing appears in the calendar.

What needs to be done to cope with that situation?

Regards…..

Profile
 
 
Posted: 26 April 2006 04:09 PM   [ Ignore ]   [ # 11 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19293
Joined  06-03-2002

I think you could try:

{exp:weblog:calendar <?php if ($c_id != "") { echo 'category="'.$c_id.'"'; } ?> switch="calendarToday|calendarCell"}
 Signature 
Profile
MSG
 
 
Posted: 26 April 2006 07:57 PM   [ Ignore ]   [ # 12 ]  
Lab Assistant
RankRank
Total Posts:  242
Joined  02-02-2004

TO: Derek
RE: Possible Solution

That might work, provided I could figure out how to deal with the calendar being of a different—auxillary—weblog titled “XXXXXX”.

This solution shows ALL categories from BOTH weblogs, the default (weblog1) and the auxillary, designed to manage and keep separate the calendar-oriented one.

Regards….

Profile
 
 
Posted: 26 April 2006 08:24 PM   [ Ignore ]   [ # 13 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19293
Joined  06-03-2002

Did you add a weblog=“weblog_name” parameter?

 Signature 
Profile
MSG
 
 
Posted: 26 April 2006 08:56 PM   [ Ignore ]   [ # 14 ]  
Lab Assistant
RankRank
Total Posts:  242
Joined  02-02-2004

TO: Derek
RE: And….

....where would that go?

Regards….

Profile
 
 
Posted: 26 April 2006 09:09 PM   [ Ignore ]   [ # 15 ]  
Lab Assistant
RankRank
Total Posts:  242
Joined  02-02-2004

TO: Derek
RE: Eureka!

I figured out where….


And for all those who follow in my footsteps, here is the final solution:

<?php
$c_id
= substr('{segment_3}', 1);
?>

{exp
:weblog:calendar weblog="{master_weblog_name}"<?php if ($c_id != "") { echo 'category="'.$c_id.'"'; } ?>  switch="calendarToday|calendarCell" show_future_entries="yes"}

<table class="calendarBG" border="0" cellpadding="6" cellspacing="1" summary="My Calendar" width="100%">
<
tr class="calendarHeader">
<
th><div class="calendarMonthLinks"><a href="{previous_path={current_temp_set}/calendar}"><<</a></div></th>
<
th colspan="5">{date format="%F %Y"}</th>
<
th><div class="calendarMonthLinks"><a class="calendarMonthLinks" href="{next_path={current_temp_set}/calendar}">>></a></div></th>
</
tr>

<
tr>
{calendar_heading}
<td class="calendarDayHeading">{lang:weekday_abrev}</td>
{/calendar_heading}
</tr>

{calendar_rows }
{row_start}
<tr>{/row_start}

{if entries}
<td class='{switch}' align='center'>
<
a href="{day_path={current_temp_set}/index}">{day_number}</a>
{entries}
<div><a href="{title_permalink={current_temp_set}/index}">{title}</a></div>
{/entries}
</td>
{/if}

{if not_entries}
<td class='{switch}' align='center'>{day_number}</td>
{/if}

{if blank}
<td class='calendarBlank'> </td>
{/if}

{row_end}
</tr>{/row_end}
{
/calendar_rows}
</table>
{/exp:weblog:calendar}

Hope it saves YOU a fortnight.

Regards….

P.S. This is code that goes into the CALENDER template of the COMENCAL template group for the auxillary weblog COMENCAL1. The other template, the one to display the details of events is the INDEX template of the COMENCAL template group. The INDEX template is pretty much like the primary weblog’s INDEX template.

Profile
 
 
Posted: 21 May 2006 06:04 PM   [ Ignore ]   [ # 16 ]  
Lab Assistant
RankRank
Total Posts:  242
Joined  02-02-2004

TO: Anyone
RE: Limiting Entries

I’ve built a small calendar for the INDEX page of my Big Calendar activity in an attempt to indicate dates of other event items on the Big Calendar while people are perusing the details in the Index template view.

The problem is that this small calendar is showing not only the items set into the Calendar weblog, but ALSO showing the items set into the INDEX of the main weblog.

How do I filter the latter out so that only the Calendar weblog related items will be considered an “entry” in the small calendar on the Big Calendar weblog’s Index?

Regards….

Profile
 
 
Posted: 21 May 2006 06:06 PM   [ Ignore ]   [ # 17 ]  
Lab Assistant
RankRank
Total Posts:  242
Joined  02-02-2004

P.S. Here’s the segment of code for the small calendar….

<div class="sidebox">
<
div class="sidetitle">Events Calendar</div>
<
div class="side">

{exp:weblog:calendar switch="cal4|cal2" show_future_entries="yes"}

<table border="0" cellpadding="2" cellspacing="1" width="175" bgcolor="#999999" style="background-color:#999999;">
<
tr class="cal3">
<
th class="calendar-head"><div class="calendar-link"><a href="{previous_path={current_temp_set}/index}"><<</a></div></th>
<
th class="calendar-head" colspan="5">{date format="%F %Y"}</th>
<
th class="calendar-head"><div class="calendar-head"><a class="calendar-head" href="{next_path={current_temp_set}/index}">>></a></div></th>
</
tr>
<
tr>
{calendar_heading}
<td class="cal0">{lang:weekday_abrev}</td>
{/calendar_heading}
</tr>
{calendar_rows }
{row_start}
<tr>{/row_start}
{if entries}
<td class='{switch}' align='center'><a href="{day_path={current_temp_set}/index}"><b>{day_number} </b></a></td>
{/if}
{if not_entries}
<td class='{switch}' align='center'>{day_number}</td>
{/if}
{if blank}
<td class='cal3'> </td>
{/if}
{row_end}
</tr>{/row_end}
{
/calendar_rows}
</table>
{/exp:weblog:calendar}</div>
</
div>

It’s based on the small calendar in the redhead template.

Profile
 
 
Posted: 03 October 2007 07:19 PM   [ Ignore ]   [ # 18 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  141
Joined  03-10-2005

a different way
what this PHP does is allows you to dynamically keep your Categories and the Date listing functions provided by both the Calender and weblog tags.

<?
if("{segment_3}" == "all"){
$segment_3
= "all";
}ELSE{
$segment_3
= "{segment_3}";
}
if("{segment_4}" != ""){
$segment_build
= "{segment_4}";
}
if("{segment_5}" != ""){
$segment_build
.= "/{segment_5}";
}
if("{segment_6}" != ""){
$segment_build
.= "/{segment_6}";
}
?>

{exp
:weblog:categories weblog="calendar" style="linear"}
    
<a href="{path=events/index}<? echo $segment_build; ?>">{category_name}</a>
{/exp:weblog:categories}

{exp
:weblog:calendar switch="min_cal_now|min_cal_days" weblog="calendar" show_future_entries="yes"}
    {next_path
=events/category/<? echo $segment_3;?>}
    {previous_path
=events/category/<? echo $segment_3;?>}
    {calendar_rows }
        {day_path
=events/category/<? echo $segment_3;?>}
    {
/calendar_rows}
{
/exp:weblog:calendar}
 Signature 

David Rencher  lumis.com

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120538 Total Logged-in Users: 60
Total Topics: 126598 Total Anonymous Users: 44
Total Replies: 665561 Total Guests: 358
Total Posts: 792159    
Members ( View Memberlist )
Newest Members:  kreessweeper240andrew nsuntroprachel123Rach123Glenn StavaImfaelSMS!persanul