1
playsome
extcal how to duplicate view_calendar-week.php?
  • 2012/8/25 8:32

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hi everyone,

I'm looking for a bit of help from an extcal developer (Mamba, help).

What I am trying to do is duplicate view_calendar-week.php or rather I am copying all code from the file into view_week.php (after deleting all existing code from view_week.php).

What I want to do is basically duplicate the template for view_calendar-week and modify it to have a different layout, so if someone goes to view_week.php it will use the exact same code, smarty variables, etc but the template will have a different layout.

I have duplicated the extcal_view_calendar-week.html and renamed it to extcal_view_calendar-week-list.html, added this intop xoops_version.php and updated the module.

Everything works ok so far, no errors, etc using same code as view_calendar-week in view_week.php but view_week.php still seems to use the extcal_view_calendar-week.html template and not the duplicated one.

I think the issue may be with this line:

$params = array('view' => _EXTCAL_NAV_CALWEEK'file' => _EXTCAL_FILE_CALWEEK);
and the constants contained in that line, I can see where the constants are defined but I cant see or figure out how a template is assigned to a particular php file. In view_calendar-week.php I was expecting something like

xoopsTpl->assign('put_new_template_file_here');


but I dont see it. Can anyone tell me how a template file is assigned to a particular php file?

Cheers

2
playsome
Re: extcal how to duplicate view_calendar-week.php?
  • 2012/8/25 8:36

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Oops, I think I just found where the template is assigned to the file. I looked for it so much I couldnt see it.

Seems to be line 6
$GLOBALS['xoopsOption']['template_main'] = "extcal_view_{$params['view']}.html";

3
playsome
Re: extcal how to duplicate view_calendar-week.php?
  • 2012/8/25 9:04

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


OK, got it sorted i think. view_week.php now uses the new template, I have just one final question.

Could I eventually run into some issues by basically pasting code from one php file into another?

Cheers

4
playsome
Making extcal template responsive?
  • 2012/8/28 19:20

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


Hi everyone,

I am needing a bit of help on getting my duplicated view_calendar_week template as described above to be responsive.

The media queries/css part isnt the problem, the problem seems to lie with the way the day weeks are displayed in the template using <{foreach}>

Heres the code of the template

<{foreach item=weekdayName from=$weekdayNames}>
        <
h2><{$weekdayName}></h2>
        <{/foreach}>
   
        <{foreach 
item=day from=$week}>
        
            
            <{foreach 
item=event from=$day.events}>
            <{if 
$event}>

            <{include 
file="db:extcal_info_bulle.html"}>

            <
div style="background-color:#<{$event.cat.cat_color}>; height:2px; font-size:2px;">
                &
nbsp;</div>
            <{/if}>
            <{/foreach}>
       
        <{/foreach}>


If we are using a table, this is fine, the days can be enclosed in a <td> and will go along the top of the table horizontally, but to better suited for mobile (I have tried numerous responsive table approaches and none work that well), I am wanting to have the days and events displayed as a list like so:

Monday
event for monday
another event for monday

Tuesday
some tuesday event
another event

and so on.

But like I said because of the <{foreach}> which is used to display the days the days display first and then the events at the very bottom instead of each event for a particular day displaying underneath the particular day.

The php code to retrieve and assign the week day names to the template is:

// Retriving weekdayNames
$weekdayNames Calendar_Util_Textual::weekdayNames(); 
for (
$i 0$i $xoopsModuleConfig['week_start_day']; $i++) {
    
$weekdayName array_shift($weekdayNames);
    
$weekdayNames[] = $weekdayName;
}
// Assigning weekdayNames to the template
$xoopsTpl->assign('weekdayNames'$weekdayNames);


Is there away, using smarty or php or both that I could perhaps get the day name using its index in the array, display this in the template and still have the correct events listed under each day?

Thanks for your help


5
playsome
Re: extcal how to duplicate view_calendar-week.php?
  • 2012/8/28 20:52

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


I have tried some code I found on the smarty.net forums

<{foreach item=weekdayName from=$weekdayNames}>
        <{if 
$weekdayName == 'Monday'}>
        <
h2><{$weekdayName.value|escape:'htmlall':'UTF-8'}></h2>
        <
div>
        <{foreach 
item=day from=$week}>
        <{foreach 
item=event from=$day.events}>
            <{if 
$event}>

            <{include 
file="db:extcal_info_bulle.html"}>

           
            <{/if}>
            <{/foreach}>
       
        <{/foreach}>
        </
div>
        <{/if}>
        <{if 
$weekdayName == 'Tuesday'}>
        <
h2><{$weekdayName.value|escape:'htmlall':'UTF-8'}></h2>
        <
div>
        <{foreach 
item=day from=$week}>
        <{foreach 
item=event from=$day.events}>
            <{if 
$event}>

            <{include 
file="db:extcal_info_bulle.html"}>

           
            <{/if}>
            <{/foreach}>
       
        <{/foreach}>
        </
div>
        <{/if}>


However the nested foreach loops that get/display the events is causing me havoc, it still displays the same events under each day, see screenshot.

Resized Image


If any one can help out here it would be much appreciated. I think this would be good for general release in the next update of the module since responsive design is popular right now, makes sense to have templates which are good for mobile.

Thanks

Login

Who's Online

190 user(s) are online (136 user(s) are browsing Support Forums)


Members: 0


Guests: 190


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits