I have successfully managed to install sfDoctrineActAsTaggablePlugin, added the Taggable behavior to the model I want to be taggable in schema.yml and rebuilt all models. Can someone point me to a tutorial that shows how to attach the tags to an object and retrieve the objects tags? I am not sure where to go from here. I am looking for a very simple solution. Something that allows me add tags separated by commas and retrieve them. Thanks.
As defined in the README file, it's as easy as this:
Consider a Doctrine "Post" class:
$post = new Post();
$post->addTag('toto');
$post->addTag('tata, tutu');
$post->addTag(array('Titi', 'Gros Minet'));
$post->save();
The plugin supports machine tags:
$post = new Post();
$post->addTag('iso:isbn=123456789');
$post->save();
// assume City is a taggable class
$city = new City();
$city->addTag('geo:lat=47.3456');
$city->save();
Related
I want to display just students in moodle users page without manually adding a filter using the web interface. Could anybody help me on how to do?
You can create a link that shows only students but you'll need to post the data. Here's how I did it.
If you install WebDeveloper - http://chrispederick.com/work/web-developer/
Then go to /admin/user.php and click WebDeveloper, choose the "Forms" tab and "convert POSTS to GETS".
Choose the filter and click add filter. This will display a url with all the form fields. Moodle is expecting a POST rather than a GET though.
So copy and paste the url into a variable and use the single_button function with the post method eg:
$url = '/admin/user.php?sesskey=xxxxxxx&_qf__user_add_filter_form=1&mform_showmore_id_newfilter=1&mform_isexpanded_id_newfilter=1&realname_op=0&realname=&lastname_op=0&lastname=&firstname_op=0&firstname=&email_op=0&email=&city_op=0&city=&country_op=0&confirmed=&suspended=&profile_fld=0&profile_op=0&profile=&courserole_rl=5&courserole_ct=0&courserole=&systemrole=0&cohort_op=2&cohort=&username_op=0&username=&auth=&deleted=&addfilter=Add+filter';
echo $OUTPUT->single_button($url, get_string('student'), 'post');
Copy and paste your own url rather than the above.
You can probably remove a lot of the parameters. You should also get the roleid for the student and use the moodle_url function, eg:
$studentroleid = $DB->get_field('role', 'id', array('shortname' => 'student'));
$params = array('courserole_rl' => $studentroleid, 'courserole_ct' => 0, ... );
$url = new moodle_url('/admin/user.php', $params);
echo $OUTPUT->single_button($url, get_string('students'), 'post');
This is not possible, as, in Moodle, it is rare for someone to be assigned the role of 'student' at the system level (and if you did, they would have access to every course on the site).
The concept of 'student' in Moodle only makes sense at the course level.
I've implemented a REST/CRUD backend by following this article as an example: http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/ . I have MongoDB running locally, I'm not using MongoLabs.
I've followed the Google tutorial that uses ngResource and a Factory pattern and I have query (GET all items), get an item (GET), create an item (POST), and delete an item (DELETE) working. I'm having difficulty implementing PUT the way the backend API wants it -- a PUT to a URL that includes the id (.../foo/) and also includes the updated data.
I have this bit of code to define my services:
angular.module('realmenServices', ['ngResource']).
factory('RealMen', function($resource){
return $resource('http://localhost\\:3000/realmen/:entryId', {}, {
query: {method:'GET', params:{entryId:''}, isArray:true},
post: {method:'POST'},
update: {method:'PUT'},
remove: {method:'DELETE'}
});
I call the method from this controller code:
$scope.change = function() {
RealMen.update({entryId: $scope.entryId}, function() {
$location.path('/');
});
}
but when I call the update function, the URL does not include the ID value: it's only "/realmen", not "/realmen/ID".
I've tried various solutions involving adding a "RealMen.prototype.update", but still cannot get the entryId to show up on the URL. (It also looks like I'll have to build the JSON holding just the DB field values myself -- the POST operation does it for me automatically when creating a new entry, but there doesn't seem to be a data structure that only contains the field values when I'm viewing/editing a single entry).
Is there an example client app that uses all four verbs in the expected RESTful way?
I've also seen references to Restangular and another solution that overrides $save so that it can issue either a POST or PUT (http://kirkbushell.me/angular-js-using-ng-resource-in-a-more-restful-manner/). This technology seems to be changing so rapidly that there doesn't seem to be a good reference solution that folks can use as an example.
I'm the creator of Restangular.
You can take a look at this CRUD example to see how you can PUT/POST/GET elements without all that URL configuration and $resource configuration that you need to do. Besides it, you can then use nested resources without any configuration :).
Check out this plunkr example:
http://plnkr.co/edit/d6yDka?p=preview
You could also see the README and check the documentation here https://github.com/mgonto/restangular
If you need some feature that's not there, just create an issue. I usually add features asked within a week, as I also use this library for all my AngularJS projects :)
Hope it helps!
Because your update uses PUT method, {entryId: $scope.entryId} is considered as data, to tell angular generate from the PUT data, you need to add params: {entryId: '#entryId'} when you define your update, which means
return $resource('http://localhost\\:3000/realmen/:entryId', {}, {
query: {method:'GET', params:{entryId:''}, isArray:true},
post: {method:'POST'},
update: {method:'PUT', params: {entryId: '#entryId'}},
remove: {method:'DELETE'}
});
Fix: Was missing a closing curly brace on the update line.
You can implement this way
$resource('http://localhost\\:3000/realmen/:entryId', {entryId: '#entryId'}, {
UPDATE: {method: 'PUT', url: 'http://localhost\\:3000/realmen/:entryId' },
ACTION: {method: 'PUT', url: 'http://localhost\\:3000/realmen/:entryId/action' }
})
RealMen.query() //GET /realmen/
RealMen.save({entryId: 1},{post data}) // POST /realmen/1
RealMen.delete({entryId: 1}) //DELETE /realmen/1
//any optional method
RealMen.UPDATE({entryId:1}, {post data}) // PUT /realmen/1
//query string
RealMen.query({name:'john'}) //GET /realmen?name=john
Documentation:
https://docs.angularjs.org/api/ngResource/service/$resource
Hope it helps
I have one to many relationship between a Post which has many comments of the domain Comment. In my gsp I´m showing a blog post with it´s comments below, at the end, there is form a user can fill out in order to create a new comment. So I´m passing the params filled in the form to a controller in order to save the new comment, but I´m not sure if I have to do it in the PostController (one side) or in the CommentController (many side). And second how exactly should I save the new comment, I used this, CommentController:
def save() {
def p = new Comment(params)
p.save()
redirect(action: 'blog', controller: 'Post', params: params)
}
Which at the end redirects to the PostController where I render the post view with the all the content including the new comment, PostController
def blog()
{
def post = Post.get(params.id)
def entra = Post.findById(params.id)
[post: post, articulos: entra]
}
" but I´m not sure if I have to do it in the PostController (one side)
or in the CommentController (many side)."
Controllers are not domain objects and are not involved in the relationship between Post and Comment. You can create a controller called PoopyCakaController and do the logic there. It is really irrelevant. Given that info, in my opinion, I guess it depends on whether multiple objects can have comments. If post owns those comments and no other objects have comments, do it in the post controller, otherwise do it in the comment controller.
"And second how exactly should I save the new comment, I used this,
CommentController:"
Is that working for you? If so, that's fine. If it is not working for you, post what the problem is including any errors you are getting.
3 I am getting error in sending mail.here below i have mentioned my code.
in controller file
var $components = array('RequestHandler', 'Filter','Image','Email','Captcha','RandomHelper');
then in my function i have write
$this->Email->from = $from;
$this->Email->subject = 'Approval Form: ';
$this->Email->delivery = 'debug';
$this->Email->template = 'adminemail';
$this->Email->sendAs = 'html';
$this->Email->send();
i dont want to send mail using SMTP. when i run this code the error is for missing helper file it tel me "rror: The helper file app/views/helpers/email.php can not be found or does not exist." Anyone can pls help me
Email is not a helper, it was a component in 1.3 and in 2.0 there is CakeEmail
You do not load helpers in the component property, use public $helpers = array('MyHelper');
Helpers are loaded without the "Helper" suffix in the $helpers property.
It looks like you do not have any idea of what MVC is or what the difference between helpers and components are. I suggest you to read about MVC and CakePHPs different parts like what the difference is between a component and a helper and a behavior for example.
Please refer to CakePHP 2.x Documentation about CakeMail or to the CakePHP 1.3 Documentation about the Email Core Component if you are using this version of CakePHP.
(Cake)Email has never been a Helper, Helper are for Views, Component are for Controllers, Behavior for Models.
They allow you to externalize part of the logic to reuse it somewhere else.
In Views, you can also use Elements for elements you use often.
we are using Perl and cpan Modul FeedPP to parse RSS Feeds.
The Perl script runs trough the different items of the RSS Feeds and save the link to the database, liket his:
my $response = $ua->get($url);
if ($response->is_success) {
my $feed = XML::FeedPP->new( $response->content, -type => 'string' );
foreach my $item ( $feed->get_item() ) {
my $link = $item->link();
[...]
$url contains the URL to an RSS Feed, like http://my.domain/RSS/feeds.xml
in this case, $item->link() will contain links to the RSS article, like http://my.domain/topic/myarticle.html
The Problem is, some webservers (which provides the RSS feeds) does an HTTP refer in order to add an session ID to the URL, like this: http://my.domain/RSS/feeds.xml;jsessionid=4C989B1DB91D706C3E46B6E30427D5CD.
The strange think is, that feedPP seams to add this session-ID to the link of every item. So $item->link() contain links to the RSS article, like http://my.domain/topic/myarticle.html;jsessionid=4C989B1DB91D706C3E46B6E30427D5CD
Even if the original link does not contain an session ID.
Is there a way to turn of that behavior of feedPP??
Thank you for any kind of help.
I took a look through http://metacpan.org/pod/XML::FeedPP but didn't see any way to turn have the link() method trim those session IDs for you. (I'm using XML::FeedPP in one of my scripts and the site I happen to be parsing doesn't use session IDs.)
So I think the answer is no, not currently. You could try contacting the author or filing a bug.
IMHO, the behavior is correct: uri components which follow a semi-colon are defined part of the path (configuration parameter for interpretation), so when the uri is used to make a relative url into an absolute uri it needs to be copied as well.
You expect compatible behavior with '&' parameters, but they are not equal.
https://rt.cpan.org/Ticket/Display.html?id=73895