We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
I just downloaded the starter kid and came across this:
@if ( ! Auth::check()) You need to be logged in to add comments.<br /><br /> Click <a href="{{{ URL::to('user/login') }}}">here</a> to login into your account. @elseif ( ! $canComment ) You don't have the correct permissions to add comments. @else @if($errors->has()) <div class="alert alert-danger alert-block"> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif <h4>Add a Comment</h4> <form method="post" action="{{{ URL::to($post->slug) }}}"> <input type="hidden" name="_token" value="{{{ Session::getToken() }}}" /> <textarea class="col-md-12 input-block-level" rows="4" name="comment" id="comment">{{{ Request::old('comment') }}}</textarea> <div class="form-group"> <div class="col-md-12"> <input type="submit" class="btn btn-default" id="submit" value="Submit" /> </div> </div> </form> @endif @stop
Excuse me - but this is crazy. Incredible amount of unnecessary work in our views, which is also unmaintainable.
Correct way should be:
View::composer(array('site.view_post'), function($view) { if( ! Auth::check()) return $view->nest('commentForm', 'site.partials.login'); // Handle $canComment here, preferably render error partial // Finally return $view->nest('commentForm', 'site.partials.commentForm', array('postID' => $postID, 'identifier' => $identifier)) });
Now, you can bind the comment form whereever you want only by adding view name into the composer array.
What benefits do you get?
The text was updated successfully, but these errors were encountered:
Agreed. I'll add this in.
Sorry, something went wrong.
View::composer(array('*view_post'), function($view) { $viewdata=$view->getData(); if(!Auth::check()) return $view->nest('commentForm', 'site/blog/comment_auth'); if(!$viewdata['canComment']) return $view->nest('commentForm', 'site/blog/comment_perm'); return $view->nest('commentForm', 'site/blog/comment_form', array('post' => $viewdata['post'])); });
Then split out the html to seperate files, comment_auth, _perm and _form and replace them with {{ $commentForm }} in view_post
andrewelkins#236 Use view composer for comment form
0de2d19
With suggestions from @Aristona and @gcphost
Use view composer for comment form andrewelkins#236
416dad7
Merge pull request #397 from baopham/feature/comment-composer
3a54514
#236 Use view composer for comment form
No branches or pull requests
Hi,
I just downloaded the starter kid and came across this:
Excuse me - but this is crazy. Incredible amount of unnecessary work in our views, which is also unmaintainable.
Correct way should be:
Now, you can bind the comment form whereever you want only by adding view name into the composer array.
What benefits do you get?
5, Generally, a better practice use.
The text was updated successfully, but these errors were encountered: