682 search results

<turbo-frame id="product-{{ product.id }}-review">
{% for review in product.reviews %}
<div class="component-light my-3 p-3">
<p><i class="fas fa-user-circle me-2"></i>{{ review.owner.email }} <i class="fas fa-star ms-4"></i> {{ review.stars }}/5</p>
<div>
{{ review.content }}
</div>
</div>
{% else %}
<p>This product has not been reviewed yet!</p>
{% endfor %}
</turbo-frame>
See Code Block in Script
…information about new notifications, new surveys, new configuration (new menu item) etc. Now we are sure we will add Turbo for the web part and the idea of pushing new information and configuration to the website client is a great topic to consider. Thank you!
…of a "single page app" feel. At first, you are probably wondering (as I did) something like: > How? If Turbo changes clicks/submits to Ajax calls... but those requests STILL return the same full HTML page, how is that "faster"? The answer (or at…
weaverryan
weaverryan
Read Full Comment
128 lines | src/Controller/ProductController.php
// ... lines 1 - 20
class ProductController extends AbstractController
{
// ... lines 23 - 71
/**
* @Route("/product/{id}/reviews", name="app_product_reviews")
*/
public function productReviews(Product $product, CategoryRepository $categoryRepository, Request $request, EntityManagerInterface $entityManager, HubInterface $mercureHub)
{
// ... lines 77 - 82
if ($request->isMethod('POST')) {
// ... lines 84 - 85
$update = new Update(
'product-reviews',
'<turbo-stream action="update" target="product-quick-stats"><template>QUICK STATS CHANGED!</template></turbo-stream>'
);
$mercureHub->publish($update);
// ... lines 91 - 109
}
// ... lines 111 - 117
}
// ... lines 119 - 126
}
See Code Block in Script
53 lines | templates/product/show.html.twig
{% extends 'product/productBase.html.twig' %}
{% block productBody %}
<turbo-frame id="product-info" target="_top" class="row pt-3 product-show">
// ... lines 5 - 31
<div class="p-3 mt-4 d-flex justify-content-between flex-wrap flex-lg-nowrap">
<div id="product-quick-stats">
<strong>{{ product.priceString|format_currency('USD') }}</strong>
<br>
<strong>{{ product.reviews|length }}</strong> Reviews
<br/>
<strong>{{ product.averageStars }}/5</strong><i class="fas fa-star ms-2"></i>
</div>
<div>
{{ include('product/_cart_add_controls.html.twig') }}
</div>
</div>
// ... line 44
</turbo-frame>
// ... lines 46 - 48
<h3>Reviews</h3>
{{ include('product/_reviews.html.twig') }}
{% endblock %}
See Code Block in Script
…the login page... or pop up a login modal (if you're using a frontend framework) or whatever is appropriate. For others, we talked about how to handle this with Turbo Frames just a few days ago https://symfonycasts.com/screencast/turbo/login-redirect Cheers!
weaverryan
weaverryan
Read Full Comment
105 lines | src/Controller/ProductAdminController.php
// ... lines 1 - 31
/**
* @Route("/new", name="product_admin_new", methods={"GET","POST"})
*/
public function new(Request $request): Response
{
// ... lines 37 - 55
return $this->renderForm('product_admin/' . $template, [
'product' => $product,
'form' => $form,
'formTarget' => $request->headers->get('Turbo-Frame', '_top')
]);
}
// ... lines 63 - 105
See Code Block in Script
<div
class="modal fade"
tabindex="-1"
aria-hidden="true"
data-modal-form-target="modal"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ modalTitle }}</h5>
<button type="button" class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<turbo-frame
class="modal-body"
src="{{ modalSrc }}"
id="{{ id }}"
>
{{ modalContent|default('Loading...') }}
</turbo-frame>
</div>
</div>
</div>
See Code Block in Script
104 lines | src/Controller/ProductAdminController.php
// ... lines 1 - 61
/**
* @Route("/{id}/edit", name="product_admin_edit", methods={"GET","POST"})
*/
public function edit(Request $request, Product $product): Response
{
// ... lines 68 - 82
return $this->renderForm('product_admin/edit.html.twig', [
'product' => $product,
'form' => $form,
'formTarget' => $request->headers->get('Turbo-Frame', '_top')
]);
}
// ... lines 89 - 104
See Code Block in Script
54 lines | templates/product/show.html.twig
// ... lines 1 - 2
{% block productBody %}
<div class="row pt-3 product-show">
<turbo-frame id="product-info" target="_top">
<div class="col-4">
<img
alt="{{ product.name }}"
src="{{ asset('/uploads/products/'~product.imageFilename) }}"
class="d-block"
>
<div class="p-2">
<small>brought to you by </small>
<small class="d-inline">{{ product.brand }}</small>
</div>
</div>
<div class="col-8 px-3">
<h1>
{{ product.name }}
{% if is_granted('ROLE_ADMIN') %}
<a
href="{{ path('product_admin_edit', {
id: product.id
}) }}"
class="btn btn-sm btn-secondary"
>Edit</a>
{% endif %}
</h1>
<div>
{{ product.description }}
</div>
<div class="p-3 mt-4 d-flex justify-content-between flex-wrap flex-lg-nowrap">
<div>
<strong>{{ product.priceString|format_currency('USD') }}</strong>
<br>
<strong>{{ product.reviews|length }}</strong> Reviews
<br/>
<strong>{{ product.averageStars }}/5</strong><i class="fas fa-star ms-2"></i>
</div>
<div>
{{ include('product/_cart_add_controls.html.twig') }}
</div>
</div>
</div>
</turbo-frame>
</div>
// ... lines 47 - 54
See Code Block in Script
52 lines | templates/product/show.html.twig
// ... lines 1 - 3
<turbo-frame id="product-info" target="_top" class="row pt-3 product-show">
<div class="col-4">
<img
alt="{{ product.name }}"
src="{{ asset('/uploads/products/'~product.imageFilename) }}"
class="d-block"
>
<div class="p-2">
<small>brought to you by </small>
<small class="d-inline">{{ product.brand }}</small>
</div>
</div>
<div class="col-8 px-3">
<h1>
{{ product.name }}
{% if is_granted('ROLE_ADMIN') %}
<a
href="{{ path('product_admin_edit', {
id: product.id
}) }}"
class="btn btn-sm btn-secondary"
>Edit</a>
{% endif %}
</h1>
<div>
{{ product.description }}
</div>
<div class="p-3 mt-4 d-flex justify-content-between flex-wrap flex-lg-nowrap">
<div>
<strong>{{ product.priceString|format_currency('USD') }}</strong>
<br>
<strong>{{ product.reviews|length }}</strong> Reviews
<br/>
<strong>{{ product.averageStars }}/5</strong><i class="fas fa-star ms-2"></i>
</div>
<div>
{{ include('product/_cart_add_controls.html.twig') }}
</div>
</div>
</div>
</turbo-frame>
// ... lines 45 - 52
See Code Block in Script
18 lines | templates/product_admin/edit.html.twig
// ... lines 1 - 4
{% block body %}
<div class="container mt-4">
<a href="{{ path('product_admin_index') }}"><i class="fas fa-caret-left"></i> Back to list</a>
<turbo-frame id="product-info" target="_top">
<div class="d-flex justify-content-between">
<h1 class="mt-3">Edit Product</h1>
{{ include('product_admin/_delete_form.html.twig') }}
</div>
{{ include('product_admin/_form.html.twig', {'button_label': 'Update'}) }}
</turbo-frame>
</div>
{% endblock %}
See Code Block in Script
<turbo-frame id="product-review">
{% for review in product.reviews %}
<div class="component-light my-3 p-3">
<p><i class="fas fa-user-circle me-2"></i>{{ review.owner.email }} <i class="fas fa-star ms-4"></i> {{ review.stars }}/5</p>
<div>
{{ review.content }}
</div>
</div>
{% else %}
<p>This product has not been reviewed yet!</p>
{% endfor %}
<hr>
{% if reviewForm|default(false) %}
<h4>Post your own review</h4>
{{ form_start(reviewForm, {
'action': path('app_product_reviews', { id: product.id })
}) }}
{{ form_row(reviewForm.stars) }}
{{ form_row(reviewForm.content) }}
<button class="btn btn-primary" formnovalidate>Add Review</button>
{{ form_end(reviewForm) }}
{% elseif not is_granted('ROLE_USER') %}
<p><a href="{{ path('app_login') }}">Log in</a> to post your review</p>
{% endif %}
</turbo-frame>
See Code Block in Script
<turbo-frame id="cart-sidebar" target="_top">
<div class="component-light product-show p-3 mb-5">
<h5 class="text-center">Featured Product!</h5>
<a href="{{ path('app_product', { id: featuredProduct.id }) }}">
<img
alt="{{ featuredProduct.name }}"
src="{{ asset('/uploads/products/'~featuredProduct.imageFilename) }}"
class="d-block"
>
</a>
<div class="pt-3">
<h6 class="d-flex justify-content-between mb-3">
<strong>{{ featuredProduct.name }}</strong>
{{ featuredProduct.priceString|format_currency('USD') }}
</h6>
{{ include('product/_cart_add_controls.html.twig') }}
</div>
</div>
</turbo-frame>
See Code Block in Script
<turbo-frame id="cart-sidebar">
<div class="component-light product-show p-3 mb-5">
<h5 class="text-center">Featured Product!</h5>
<a href="{{ path('app_product', { id: featuredProduct.id }) }}">
<img
alt="{{ featuredProduct.name }}"
src="{{ asset('/uploads/products/'~featuredProduct.imageFilename) }}"
class="d-block"
>
</a>
<div class="pt-3">
<h6 class="d-flex justify-content-between mb-3">
<strong>{{ featuredProduct.name }}</strong>
{{ featuredProduct.priceString|format_currency('USD') }}
</h6>
{{ include('product/_cart_add_controls.html.twig') }}
</div>
</div>
</turbo-frame>
See Code Block in Script
23 lines | templates/weather/index.html.twig
// ... lines 1 - 2
{% block body %}
<h1>The Weather!</h1>
<turbo-frame id="weather_widget">
<a class="weatherwidget-io" href="https://forecast7.com/en/40d71n74d01/new-york/" data-label_1="NEW YORK" data-label_2="WEATHER" data-theme="original" >NEW YORK WEATHER</a>
<script>
!function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = 'https://weatherwidget.io/js/widget.min.js';
fjs.parentNode.insertBefore(js, fjs);
}
}(document, 'script', 'weatherwidget-io-js');
</script>
</turbo-frame>
{% endblock %}
// ... lines 21 - 23
See Code Block in Script
…just into the code highlighting stuff for blog posts with shell scripts/source code. Expanding is not needed by me. And, by the way, many, many thanks for your great videos. Currently I’m into Stimulus, looking forward to Turbo. Keep on that great work.
Yes! It worked! You're the King, Ryan! Thank you for your help and, once again, for your great tutorials. I'm looking forward to the next one on "Turbo". Cyril
…show" buttons into real anchor tags with real URLs (and if you go to those URLs, you would see the page rendered with the correct trees open), then you could use Turbo. Basically, it would "reload" (without a full page refresh) the entire tree structure…
weaverryan
weaverryan
Read Full Comment
…it in the last year. But you totally convinced me. I love stimulus ;) and I love your tutorials. I can totally see, why you decided to use that hotwire ecosystem. I can't wait for the turbo one. Good job Ryan! Thanks for your efforts.
Braunstetter
Braunstetter
Read Full Comment