Managing different views

Managing different views

by Justin Hunt -
Number of replies: 15
Picture of Particularly helpful Moodlers Picture of Plugin developers

I have been trying to put together a dataform activity. But I am not quite sure how to achieve something. I suspect it is pretty simple though.

I define 3 view's, lets say "listview,"  "moreview" and "entryview."

I want to show a link beneath each entry in the listview, to that particular entry in the "moreview."

Similarly the "entryview" is for adding a new entry. The layout (and content) of the "listview" and "moreview" are not really appropriate for when the user is creating a new entry, in this case.

I see there are nice patterns I can use within one view, to link to the selected entry on its own page( EAC:more ), or to go to the add a new entry page ( ##addnewentry## ) . But they are using the same view. 

Is there a way to do this, basically, link from one view to another view? 



Average of ratings: -
In reply to Justin Hunt

Re: Managing different views

by Itamar Tzadok -

Yes. There are many other patterns which are not visible via the UI and only some are currently listed in the docs.

In the entry level you can use (note redundant spaces between brackets)

[ [EAC:more:viewname]]
[ [EAC:edit:viewname]]

Which will send you to view or edit (respectively) the entry in the specified view.

Also

[ [EAC:moreurl:viewname]]

which you can use in the href of a tag to create a custom link to the target view.


In the view level you can use:

##viewurl:viewname## 

which displays the url of the specified view and you can use in the href of a tag.

##viewlink:viewname## 
which displays a link to the specified view

There is also a composite version of the viewlink pattern which looks like this:
##viewlink:Single view;Add a new entry;editentries=-1;##
This particular instance will mimic the addnewentry pattern but in the specified view. Details on the syntax should be available in this post: https://moodle.org/mod/forum/discuss.php?d=256813#p1123734.

The view patterns are also parsed in the entry level so you can use the composite viewlink pattern in the entry with the entry id pattern:
##viewlink:Edit view;Edit this submission;editentries=[ [entryid]];##
or

##viewlink:Details view;More details ...;eids=[ [entryid]];##

Another view pattern that is not really related to your current purpose but is good to know is
##viewcontent:viewname## 
which displays the content of the specified view. You can create an overview view which displays the content of several views in the acivity by adding viewcontent patterns in the view template of the overview. The entry template of the overview can be empty.

Another relevant view function you might already be aware of is redirection of the view to another view in the activity after form submission. You can find the setting under the 'Submission' section in the view configuration form. There you can also set the redirection timeout and message, and also add additional submission buttons as well as custom labels for these buttons.

hth smile
Average of ratings: Useful (2)
In reply to Itamar Tzadok

Re: Managing different views

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

That's exactly what I was hoping to hear. 

Thanks for the detailed reply.


In reply to Justin Hunt

Re: Managing different views

by Itamar Tzadok -
There is also the ##newentry## pattern which you can use in the view template section instead of the ##entries## pattern to display only a new entry form. In such a use case you would typically set the view submission redirection to some other view, unless the view is a contact form in which case you would want to continue displaying a new entry form after submission. hth smile
In reply to Itamar Tzadok

Re: Managing different views

by Iruma Tenji -
Hi Itamar,

Can you explain more of this feature, or any step and guideline to set this up:
##viewcontent:viewname## 
i have view1 (Tabular) and view2 (Tabular)
and i wish to combine this two views in a single view
and i think this viewcontent may help it, but i don't know how to set it up
Please help

Thanks
In reply to Iruma Tenji

Re: Managing different views

by Hartmut Scherer -

Hi Iruma,

When you write 

##viewcontent:view1##

##viewcontent:view2##

into the view template of the merged view (e.g. Grid), you will see view1 and view2 together.

If you want to select particular fields from each view, you need to use the dataformview field which is available from git at https://github.com/itamart/moodle-dataformfield_dataformview. It requires Dataform 2.8.6. Unzip and open the downloaded file. Change the folder name to dataformview and zip it again. Use this zipped file for installation. After the installation you need to enable this field. Go to Site administration > Plugins > Activity modules > Dataform > Field plugins > Manage field plugins and search for "Dataform view." Click on the eye so that it is enabled. You can have more than one "Dataform view" field. You will need to save and continue for every step in the Dataform view field. Otherwise, you will not be able to set up the next step.

With kind regards,

Hartmut

In reply to Hartmut Scherer

Re: Managing different views

by Iruma Tenji -

Hi Hartmut,

Thanks much for your reply,

What about if i have two dataform: Dataform A and Dataform B.

And each dataform has its own view: Dataform A: View 1, View 2; Dataform B: View 1, View 2

I wish to combine this two views (Dataform A: View 1 & Dataform B: View 2) in a single view.

So ##viewcontent:## able to fulfill it? Or is there other way that i can use?

Please help.

Thanks


In reply to Iruma Tenji

Re: Managing different views

by Hartmut Scherer -

Hi Iruma,

With the dataformview field, you can fetch views or fields from all Dataform activities of your entire site, not just the Dataform activity, you are working with. Here is an example:

Selecting a Dataform activity from another course














I don't know whether you can fetch views from another Dataform activity with ##viewcontent##. 

With kind regards,

Hartmut

In reply to Hartmut Scherer

Re: Managing different views

by Iruma Tenji -

Hi Hartmut,

It is great field, and is what i am looking for.

But now i face another problem. After i add some dataform view field,

in the view tag there, i add ##entries## in view template, but when i browse it, there is not content for the dataform view field that i add.

Instead if i put ##addnewentry##, i need to press that 'Add a new entry' button after that the content will show.

Now the question is how can i see the content of the dataform view field directly.


Thanks

In reply to Iruma Tenji

Re: Managing different views

by Hartmut Scherer -

Hi Iruma,

I assume that you downloaded and installed the Dataform view field. When you open any Dataform activity > Manage > fields, do you see the "Dataform view" field in the drop down menu? If not, you need to enable Dataform view (see my previous post).

Here is a sample scenario for testing the Dataform view field.

  1. Add a new Dataform activity A with at least one field (e.g., Upload a file) and a tabular view
  2. Add another Dataform activity B with a field Textarea (for comments) and a tabular view
  3. Let a test student add a file in Dataform A and a comment in Dataform B
  4. Add another Dataform activity C. This will be the one in which you want to see Dataform A and Dataform B
  5. Add a field Dataform view, name it viewA and select Dataform activity A in Settings. After a selection, you need to save it and open Dataform view field again for the next selection. You have to save each step in Settings before you can see and select the next step.
  6. Add a second field Dataform view, name it viewB and select Dataform activity B in Settings.
  7. Add a view, for example a Grid view. The View template should only have ##entries##. In the Entry template, add [[viewA] ] [[viewB] ] (leave out the extra space between the square brackets)
  8. Now you should see in Dataform C the content of Dataform A and B.
With kind regards,

Hartmut

In reply to Hartmut Scherer

Re: Managing different views

by Iruma Tenji -

Hi Hartmut,

i had follow every steps, but start at step 7 & 8, it can't work at my site, especially when i add ##entries## in the View template, no content of viewA] ] [[viewB are shown.

Is there any part i miss or is there any setting i have to do? my dataform is version 2.9

Thanks

In reply to Iruma Tenji

Re: Managing different views

by Hartmut Scherer -

Hi Iruma,

I tried to merge views all morning, but I get the same result like you. No entries are showing up in Dataform Activity C. I tried it in my test site and our life site - empty page. Debug is on developer mode in my test site, but there is no error message showing up. 

I can see the entries in the individual views, i.e., the uploaded file in viewA and the comment in viewB, but in the Dataform Activity C the Dataform view field seems to be unable to fetch the data from Dataform activity A and B in the same course.

I added a tracker issue CONTRIB-5854.

With kind regards,

Hartmut

In reply to Iruma Tenji

Re: Managing different views

by Hartmut Scherer -

Hi Iruma,

Add in step #7 in the view template ##newentry## in addition to ##entries##. When you view Dataform C and click on "Add a new entry," you should see the entries of the other Dataform activities. I learned this from Itamar Tzadok.

With kind regards,

Hartmut

In reply to Hartmut Scherer

Re: Managing different views

by Itamar Tzadok -

The pattern for the 'Add a new entry' button is ##addnewentry##. smile

In reply to Itamar Tzadok

Re: Managing different views

by Iruma Tenji -

Hi All,

Thanks for the reply.

Actually what i want is add ##entries## in the view template, so that user can see the content directly.

Is there any way can improve this?

It is great if it can be done by adding ##entries## in the view template.

Thanks