help to better help you:

Please: add always Joomla / JEM version and details to your posts, so we can try to reproduce your issue!

Using JEM for a whole week event program

Re: Using JEM for a whole week event program

9 years 10 months ago
#17183
Hoffi wrote: In JEM's calendars a week (row) can start on Sunday or Monday, but not on other days. So that can only be changed by editing php files. (unfortunately the code is "optimised" to these two possibilities so these changes are a bit more complex)
Ok I'll look at this one next week...
You would like to remove the week number so I think you talk about the week calendar. There the weeknum is "hardcoded" enabled but can be disabled by changing the php code a bit (one line).
Done. That was an easy one :-)
Setting the week shown to a fixed date is not possible except... changing php code (one line). [...] Also the week calendar doesn't provide this option.
Haven't found the line to change but re-reading your sentence it seems it is not possible in the week calendar? Could you confirm or let me know in which file I can find the thing to change. Else I'll push that to next week as well ;-)
If you could live with two weeks shown the rest could be reached by changing two lines of code (as long as you don't need the week calendar view with normal behaviour in parrallel).
Not too sure what the "normal behaviour" is but I guess I could live with 2 weeks being displayed.

Please Log in or Create an account to join the conversation.

Re: Using JEM for a whole week event program

9 years 10 months ago
#17194
Hi Bfred,

ok, as you're able to adapt the code let me give you more precise hints from developer to developer. :)

The "doesn't provide this option" refered to the offset field; changing code is always possible. :cheer:
To set the fixed date the simplest (hard-coded) way is to change components/com_jem/views/weekcal/view.html.php (where you removed the week number I think ;) ) around line 65 from
Code:
$currentweek = $this->get('Currentweek');
to
Code:
$currentweek = 14;
(hope 14 is correct for Apr. 4th).

But this will always show every week calendar on your site starting with this week which isn't "normal behaviour" - if this is ok for you, fine.
Else a more "user-friendly" way could be to add a parameter field (in ./tmpl/default.xml), let's say name="fixweeknum" label="Fix week number" (more perfect as a symbolic name for translation which requires enhancing of admin language file, /administrator/components/com_jem/language/...) where you then can type in a number in corresponding menu item params. Then you could change the line from above to something like
Code:
$currentweek = (int)$params->get('fixweeknum', 0); // is the name choosen in xml file, default value 0 if (empty($currentweek) { $currentweek = $this->get('Currentweek'); }
(hint: in older php versions empty() requires a variable, not a function's return value)
Then it will use the week number if given (on menu item) or current week as "normal behaviour". B)
(of course, you could provide the field as start date field and calculate the week number inside the code - depends on the "deluxe-level" you need ;) )

regarding one week line starting Saturday:
Hadn't enough time to take a deeper look yet. But the relevant classes can be found in /components/com_jem/classes/activecalendarweek.php and ./calendar.class.php.
Also /components/com_jem/models/weekcal.php could be involved.
The following user(s) said Thank You: Bfred

Please Log in or Create an account to join the conversation.

Re: Using JEM for a whole week event program

9 years 10 months ago
#17198
OK. Really weird as I initially changed this value and only saw the current day "disappearing'. So I thought it just moved it. I re-edited the value right now and it worked... well almost worked I should say as no event is appearing in the week calendar. They do appear however in the module calendar. So I am thinking that this is happening during the extraction of events which is based on the "active" week. I'll look deeper and see if I can get that fixed.

Thanks a lot.

Please Log in or Create an account to join the conversation.

Re: Using JEM for a whole week event program

9 years 10 months ago - 9 years 10 months ago
#17203
So I am now editing models/weekcal.php to narrow down the weeks the events are being searched from. I am stuck with these lines which I'd like to replace by the first day of my events:
Code:
$datetime = new DateTime(); $datetime->setISODate($year, $datetime->format("W"), 7);

There is a logic after that about which day of the week is first, but I was hoping to be able to replace $datetime by the proper value for "my week" and be done with it. Unfortunately it is not working (or I don't seem to get the right format). Is it the right way to do and would you happen to know what format I should use. Went to the SetISODate and DateTime format pages without coming out with the proper structure.

Thank you.
Last edit: 9 years 10 months ago by Bfred.

Please Log in or Create an account to join the conversation.

Re: Using JEM for a whole week event program

9 years 10 months ago
#17207
Ah, sh... I forgot the event query. :whistle:

You're right, JemModelWeekcal::populateState() must be adapted too. Because the week calendar was designed to always start on today the model goes the simplest way. :(

At first you need to change the $datetime creation, e.g. to:
Code:
$datetime = new DateTime('2015-04-04');
But also you must replace the "time()" parts below to "$datetime->getTimestamp():
Code:
if (date('N', $datetime->getTimestamp()) == 1) {
(as well as "...== 7" some lines below)

...hm... as longer as I look at this piece of code I get the feeling this is not optimally...

I also found the same block in calendarMultiday() (to remove parts of multiday events which are outside the period to show). Maybe you don't need to change this if you don't have events with enddate > startdate, but not sure.
Because especially the line with the hard-coded date I don't like, and having it twice I don't like even less. Maybe it could become part of params (as param field in view's xml instead of fixweeknum I suggested previously) which should be respected in all cases "today" or "now" is implied (like on DateTime(), time(), date() ...) including the next function:

And in getCurrentWeek() week's start day is limited to Su and Mo (that's the function we replaced in view by fixed week number)

---

I think it should be possible and useful to replace all this specific code by a smart formula able to find every week day not after a given date. Should be no bad idea to have this as a standard feature of JEM - will make me a feature request. ;)

Please Log in or Create an account to join the conversation.

Re: Using JEM for a whole week event program

9 years 10 months ago
#17209
ok. Well I'll try with your suggestion and see what gives. Currently the test site is locally hosted and not where I am until (my) tomorrow ;-)

If this becomes too difficult I'll take a deeper look next week with someone else in my office. He hopefully should be able to help.

And yes there are events over several days. :huh:

Thank you very much for the very useful support! :P

Fred

Please Log in or Create an account to join the conversation.

Time to create page: 0.554 seconds