Link to home
Start Free TrialLog in
Avatar of jempie
jempie

asked on

How to specify view layout for calendar view on web

Hello experts,

I've got a small problem for you: I want the user to be able to select the way he sees a calendar view in an application I designed and I want him to be able to navigate to previous and next pages, depending on the layout.
For example if the layout is two days, previous should show the previous two days and next should show the next two days. The same for two weeks, it should show the previous/next two weeks.

Can this be done on the web using a $$ViewTemplate form to make the view look the way I want with buttons I designed myself?
Avatar of zvonko
zvonko

Main question!
Which style is your View: StandardOutline or Calendar?

Also Domino version for this web view would be good to know.

So long,
zvonko
Big one Zvo ??? Enjoy!
Avatar of jempie

ASKER

Sorry for the late reply, I'm using a Calendar view and Domino R5.0.5
Ok then I have a really simple solution for you.

Follow this instructions carefully

************
The customization as follows

Copy the calendar view from mail template or design one

Create a form called $$ViewTemplate for ($Calendar) (Which should obviously contain $$ViewBody )

Create two cgi fields Query_String_Decoded and Path_Info.. Hide it while reading or editing

Create Two computed for display fields adjacent to each other, and name one as Previous and other as Next

This code goes into the "Previous" field:
=========================================
qs := @LowerCase(Query_string_Decoded);
fmt :=  @Right( @Word(qs; "&"; 2) ; "=");
dtStr := @Right( @Word(qs; "&"; 3) ; "=");
@If( fmt = ""; @Return(""); "");
date := @TextToTime(dtStr);
newdt := @If(   fmt = "1";  @Adjust( date; 0; 0; -2;0;0;0);
 fmt = "2";  @Adjust( date; 0; 0; - 7;0;0;0 );
 fmt = "3";  @Adjust( date; 0; 0; -14;0;0;0 );
 fmt = "4";  @Adjust( date; 0; -1; 0;0;0;0 ); @Adjust( date; 0; 0; -1;0;0;0) );

yr := @Text(@Year(newdt));
mon := @Text(@Month(newdt));
day := @Text(@Day(newdt));

newdtStr := yr + "-" +  @Repeat( "0"; 2 - @Length(mon))  + mon + "-"+ @Repeat("0"; 2 - @Length(day)) + day;

url := @ReplaceSubstring( path_info; dtStr; newdtStr);

"[<a href=\"" + url + "\">Prev</a>]"


This code goes into the "Next" field:
=====================================
qs := @LowerCase(Query_string_Decoded);
fmt :=  @Right( @Word(qs; "&"; 2) ; "=");
dtStr := @Right( @Word(qs; "&"; 3) ; "=");
@If( fmt = ""; @Return(""); "");
date := @TextToTime(dtStr);
newdt := @If(   fmt = "1";  @Adjust( date; 0; 0; 2;0;0;0);
 fmt = "2";  @Adjust( date; 0; 0; 7;0;0;0 );
 fmt = "3";  @Adjust( date; 0; 0; 14;0;0;0 );
 fmt = "4";  @Adjust( date; 0; 1; 0;0;0;0 ); @Adjust( date; 0; 0; 1;0;0;0) );

yr := @Text(@Year(newdt));
mon := @Text(@Month(newdt));
day := @Text(@Day(newdt));

newdtStr := yr + "-" +  @Repeat( "0"; 2 - @Length(mon))  + mon + "-"+ @Repeat("0"; 2 - @Length(day)) + day;

url := @ReplaceSubstring( path_info; dtStr; newdtStr);
"[<a href=\"" + url + "\">Next</a>]"

**************
And you are all set to go
Sorry for this correction, I missed one more parameter in the calendar. So use this formula function for

Previous field
==============================
qs := @LowerCase(Query_string_Decoded);
fmt :=  @Right( @Word(qs; "&"; 2) ; "=");
dtStr := @Right( @Word(qs; "&"; 3) ; "=");
@If( fmt = ""; @Return(""); "");
date := @TextToTime(dtStr);
newdt := @If(   fmt="6"; @Adjust( date; 0; 0; -1;0;0;0); fmt = "1";  @Adjust( date; 0; 0; -2;0;0;0);
 fmt = "2";  @Adjust( date; 0; 0; -7;0;0;0 );
 fmt = "3";  @Adjust( date; 0; 0; -14;0;0;0 );
 fmt = "4";  @Adjust( date; 0; -1; 0;0;0;0 ); @Adjust( date; -1; 0; 0;0;0;0 ));

yr := @Text(@Year(newdt));
mon := @Text(@Month(newdt));
day := @Text(@Day(newdt));

newdtStr := yr + "-" +  @Repeat( "0"; 2 - @Length(mon))  + mon + "-"+ @Repeat("0"; 2 - @Length(day)) + day;

url := @ReplaceSubstring( path_info; dtStr; newdtStr);
"[<a href=\"" + url + "\">Prev</a>]"

==============================


AND Next Field
==============================
qs := @LowerCase(Query_string_Decoded);
fmt :=  @Right( @Word(qs; "&"; 2) ; "=");
dtStr := @Right( @Word(qs; "&"; 3) ; "=");
@If( fmt = ""; @Return(""); "");
date := @TextToTime(dtStr);
newdt := @If(   fmt="6"; @Adjust( date; 0; 0; 1;0;0;0); fmt = "1";  @Adjust( date; 0; 0; 2;0;0;0);
 fmt = "2";  @Adjust( date; 0; 0; 7;0;0;0 );
 fmt = "3";  @Adjust( date; 0; 0; 14;0;0;0 );
 fmt = "4";  @Adjust( date; 0; 1; 0;0;0;0 );  @Adjust( date; 1; 0; 0;0;0;0 ));

yr := @Text(@Year(newdt));
mon := @Text(@Month(newdt));
day := @Text(@Day(newdt));

newdtStr := yr + "-" +  @Repeat( "0"; 2 - @Length(mon))  + mon + "-"+ @Repeat("0"; 2 - @Length(day)) + day;

url := @ReplaceSubstring( path_info; dtStr; newdtStr);
"[<a href=\"" + url + "\">Next</a>]"

================================
Hello jempie,

it is funny how much work can be done for 500 points :-)

The best recommendation in Heman's proposal is: look into mail template.
In mail template is the form named "$$ViewTemplate for ($Calendar)"
Therein you will see that Prev and Next computed fields each contain only ONE @Formula.

For "Prev" field use:
@DbCommand("Domino"; "ViewPreviousPage")

and for "Next" field use:
@DbCommand("Domino"; "ViewNextPage")

Cheers,
zvonko

One more:
in mail template are Prev and Next fields Text parts marked as HotspotActions.

The same way you can mark your embedded images (or better ImageResources) and create for each an HotspotAction containing upper "Domino" @formulas.

Avatar of jempie

ASKER

These formula's don't seem to work.
The links seem to return me to the view navigator of the database. Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of Jean Marie Geeraerts
Jean Marie Geeraerts
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jempie

ASKER

Yes, the formula's give the expected result. Thanks a lot!
You even anticipated on another question in providing the possibility to select a different layout for the view through action buttons (or hotspots).
Thanks again.
Avatar of jempie

ASKER

Oops, looks like I should have refreshed this question before commenting. Didn't notice zvonko's comment earlier.
I'll give it a try and if it works will award some points for you too, zvonko.
Avatar of jempie

ASKER

Zvonko,
You're formula does work and is a lot simpler, so you deserve points for this too. Please see the for zvonko question in this topic area.

Regards,
jempie
Ah yes, I should have looked at the mail template and found that same solution myself :-)

I guess I got blindsighted with correcting Hemanth's formula's ;-)

I even found a much better/simpler solution for the change layout buttons too:

Create action hotspots with the following formula:
One day (new in R5):
@Command([CalendarFormat]; "1");
Two days:
@Command([CalendarFormat]; "2");
One week:
@Command([CalendarFormat]; "7");
Two weeks:
@Command([CalendarFormat]; "14");
One month:
@Command([CalendarFormat]; "30");
One year (for web only):
@Command([CalendarFormat]; "365");

Just thought I mentioned this, to proove I deserved the points :-)
<|;-)

Jempie, Is this fair accepting Jerrith's proposal which is just an extension of my work ???
Avatar of jempie

ASKER

Okay HemanthaKumar,
Here are your points for assisting me in this question : https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=lotusnotes&qid=20310781

I thought it was fair, since his formula's worked and I got an incorrect result when opening the view without paramters (as jerrith pointed out).

I have adapted the application using zvonko's and jerrith's last comments to simplify the used formula's.

Hope I didn't offend anyone,

Jempie
I would have helped you if you could have commented on my post... but before that you accepted extenstion of my comment.

It was silly of me not to think a simple solution for you (Which Zvonko did), May be next time !

Please delete the new question that you posted for me. I don't want these points. Will see next time
To honor of you Heman it should be mentioned that generally your code can be of good use in appropriate situations. I will keep it in mind :-)

Long back I had something like that, so I designed this solution and ofcourse took some time to recollect
Avatar of jempie

ASKER

Okay, I'll delete the for HemanthaKumar question.
Again, thanks for the assistance, it was still useful in the fact that I learned a bit more about @Formula's.