Thank guys
Also needed a uppercase ‘D’ for doodle was not helping the situation!!!
Amazing
Thank guys
Also needed a uppercase ‘D’ for doodle was not helping the situation!!!
Amazing
If you want to make sure, that a user can only edit his own doodles, then you probably have to use the where
property (instead of the paramname
property) because a user could just add an arbitrary id
to the URL.
[[!FormIt?
...
&where=`{"id": [[!getRequestId]], "createdby": [[!+modx.user.id]]}`
]]
This assumes your custom table has a column “createdby” that contains the id of the MODx user.
The code for the snippet getRequestId:
<?php
$value = 0;
if (isset($_REQUEST['id'])) {
$value = intval($_REQUEST['id']);
}
return $value;
Try to avoid id
is url parameter. This could be interpreted as resource - id, for example when FURLs are off.
you can’t read the hash part server side
can I use link parameter to change a property from published to unpublished?
What exactly do you mean? Like another GET parameter <a href="[[~123]]?id=[[+id]]&unpublish=1">
?
You can do that, but you’ll have to write some custom PHP code to handle such a request.
Yes
I suppose what I am trying to understand is within the loop chunk can I also delete the row (in reality unpublish)
<p>[[+username]] || [[+description]] || <a href="[[~123]]?createdon=[[+createdon]]">Edit Fields</a> || <a href="[[~[[*id]]]]?id=[[+id]]&published=0">Delete</a></p>
it returns to the loop with the row has gone
What I think i am struggling to understand is what is possible to implement (add/edit/delete) in the front end with the supplied snippets or do i always need to look at writing them…
If I do then i assume its something like this from gel in there video.
But then I don’t understand when/where or how you call the snippet as I assume this has to be during the loop call.
Also back to you previous point a constantly reloading page is a bit old hat and I should really be using Ajax for user experience.
thanks
With a link like this <a href="[[~[[*id]]]]?id=[[+id]]&published=0">Delete</a>
where you reload the same page you would probably place the snippet above the loop call.
[[!deleteRow]]
[[!migxLoopCollection? ...]]
In the snippet check if there is a $_GET parameter published
and then load the row from the database and change it with xPDO.
To make it work with AJAX you have different options.
You can create a new resource with a blank template that justs serves a an ‘AJAX endpoint’. Then call a snippet in this resource that does some stuff based on the available $_GET or $_POST parameters and returns some json.
Or you could create a full RESTful API for your use case.
Or maybe use the same resource, determine in a snippet if it is an AJAX call and change the output accordingly. pdoPage (from the extra pdoTools) does something like that.