Load CSS/Javascript in frontend conditionally if block is used

Assuming I have no unfinite scroll or anything else going on in my theme: Is there a way to enqueue my custom Gutenberg block styles and scripts so they are only (lazy) loaded in the frontend when the block is really used? Something like is_active_widget, just for blocks? If I enqueue them inside a enqueue_block_assets function they’re added to any site.

On github, I found this https://github.com/WordPress/gutenberg/issues/5445 , but it sounds like it’s more on bundling than conditional load, so I still hope they didn’t leave that optimization opportunity out – otherwise any other site will soon be junked with 20 additional scripts from numerous Gutenberg block plugins people install and only use once on a page (think of large image gallery block scripts for example).

Thanks & Regards!

Display a custom attribute below product name in the front-end Magento 1.9.3.8

I need to display a custom attribute bellow the product name and I don’t know how can I call this attribute.

I am editing the file /app/design/frontend/templatemela/MAG100219_1/template/catalog/product/view.phtml But how can I call this attribute in php? I tried calling a string echo with the name I put in the attribute, but it didn’t work.

Code is as below:

<div class="page-title product-title">  <h1><?php echo $  _helper->productAttribute($  _product, $  _product->getName(), 'name') ?></h1> </div>  <div class="codigoinmetro">  <h2><?php echo $  _helper->productAttribute($  _product, $  _product->getName(), 'registroinmetro') ?></h2> </div> 

Quando termina o trabalho do front-end e começa do back-end?

Estou me especializando em front-end e estudando Angular, fiquei com uma dúvida.

O programador front-end desenvolve as telas, no caso, em Angular ele iria criar o visual de acordo com o que lhe foi passado.

No html/css simples, ele faria, por exemplo, algo assim:

<nav>     <a href="home.php">Home</a>     <a href="about.php"> About</a> </nav> 

No caso acima, é só colocar um link e quando o usuário clicar, ele já é redirecionado para outra página.

No Angular, as páginas são feitas através de components, então “home” seria um component composto por arquivo.html, arquivo.css, arquivo.ts e arquivo.spec.ts e a mesma coisa com o about. O código ficaria mais ou menos assim:

<nav>     <a routerLink="/">Index</a>     <a routerLink="/home"> Home</a>     <a routerLink="/about/13"> About</a> </nav> 

Ainda no caso do Angular, eu posso usar service para não permitir que o usuário entre em na home, sem antes ter feito o login.

Eu gostaria de entender quando termina o trabalho do front-end e quando começa o do back-end.

Exemplo: O fron-end faria até components e o back-end implementaria o service e as outras partes?

Design-Tree for Front-End Navigation

For a part of my coding interview I received this prompt:

The attached screen comps show how a navigational menu should behave on mobile screens. Your task is to design a component tree that can render all the states of this navigational menu. Present your answer as a nested component tree in JSX-pseudocode, with any relevant props as attributes (but the props don’t have to be assigned values). Be sure to explain what each prop will be used for. For example:

<App>   <Foo fooProp>     // fooProp is used to determine if foo is blah blah blah     <NestedBar>       <NestedBaz bazProp oofProp />       // NestedBaz needs two props: bazProp determines x and oofProp determines y     </NestedBar>   </Foo> </App> 

https://gist.githubusercontent.com/mohanzhang/bd16eb1d83b2b318af0814cd667be50f/raw/7260cad31a5db70f54e6898ef31813f86633affa/comp.png

Above is a link to the mockups they’re referring to

This was my response

<App>   <Foo>     // we can pass mode and roll into a getTheme function, and pass theme into components to determine styling     <Nav mode role>       // Role is an enum for role-specific behavior. E.G, search only shows up for admin role       // mode is an enum for the type of view. E.G, dashboard/workspace/default       <NavButton onClick selected>         <Icon hasAlert showBorder size /> // Icon is a general dumb ui component class           // OR         <img src /> // sizing handled through css         <DropdownMenu>           <DropdownMenuItem showDivider>           </DropdownMenuItem>         </DropdownMenu>       </NavButton>     </Nav>     <Main mode role theme> // mode and role determine menu type       <AdminMenu>         <DropdownMenu hasDividers={false}>           <DropdownMenuItem showDivider>           </DropdownMenuItem>         </DropdownMenu>       </AdminMenu>       <SearchView>         <DropdownMenu>           <DropdownMenuItem showDivider>             <img src /> // to include images, just specify the image as a child             <span>Oliver Ullman</span>           </DropdownMenuItem>         </DropdownMenu>       </SearchView> // substitute timeline view for chatview/notifications view, ect     </Main>   </Foo> </App> 

I did the best that I could, but I have this sense that I’ve done a very poor job (I haven’t gotten a response back yet). I would really love to get some criticism on what I did, as I feel like in the future I might be able to implement this design much better. As stupid as it sounds, I’m also not great at following instructions, so, if you feel like I misinterpreted any of those instructions let me know too!

RouteNotFoundException only for logged in users on frontend

I am getting this error:

The website encountered an unexpected error. Please try again later. Uncaught PHP Exception

Symfony\Component\Routing\Exception\RouteNotFoundException: “Route “” does not exist.” at /code/core/lib/Drupal/Core/Routing/RouteProvider.php line 201

It only happens on the frontend to non logged in users. The frontend works if they are logged out and the backend works fine.

I have tried rebuilding, clearing caches, composer install, and changed themes, and haven’t found anything out of the ordinary. How can I fix this?

A few more lines of the error:

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 201 of core/lib/Drupal/Core/Routing/RouteProvider.php). Drupal\Core\Routing\UrlGenerator->getRoute('') (Line: 130) Drupal\Core\Routing\UrlGenerator->getPathFromRoute('', Array) (Line: 68) Drupal\Core\Render\MetadataBubblingUrlGenerator->getPathFromRoute('', Array) (Line: 790)  Drupal\Core\Url->getInternalPath() (Line: 135)  Drupal\Core\Utility\LinkGenerator->generate('', Object) (Line: 94)  Drupal\Core\Render\Element\Link::preRenderLink(Array) call_user_func(Array, Array) (Line: 378)  Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)  Drupal\Core\Render\Renderer->render(Array) (Line: 490)  Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 133)  __TwigTemplate_77bb9182ec2f5bb726659d7337d56f7391bfcd4d2f87fc9ccf8f299a8765d35c->getmenu_links(Array, Object, 0, Array, Array) (Line: 679)  Twig_Template->getAttribute(Object, 'menu_links', Array, 'method') (Line: 46)  __TwigTemplate_77bb9182ec2f5bb726659d7337d56f7391bfcd4d2f87fc9ccf8f299a8765d35c->doDisplay(Array, Array) (Line: 432)  Twig_Template->displayWithErrorHandling(Array, Array) (Line: 403)  Twig_Template->display(Array) (Line: 411)  Twig_Template->render(Array) (Line: 64)  twig_render_template('themes/bootstrap/templates/menu/menu.html.twig', Array) (Line: 384) 

CSS are compiled but not called in frontend

i added css on my website. One is bootstrap and one is a custom css. I addedd it on my Magento_Theme folder (inside layout/default_head_block.xml)

<css src="css/bootstrap/css/bootstrap.css" order="100" /> <css src="css/reflexmania2-custom.css" order="100" />      

suddendly there was a problem on these css. They are not loaded in the frontend css inside the HEAD tag.

i tried cleaning cache, generated folders, view_preprocessed and then running

setup:upgrade setup:di:compile setup:static-content:deploy  

but nothing. they are not loaded.

they are compiled because i can see inside my pub/static folder.

i’m getting crazy. How can i solve this problem?

Thanks for help

What is a good way to add extra info to data-entries from a website front-end?

I want users to be able to dynamically add ‘columns’ from the front-end of the website. I understand that it is probably not best practice to actually add columns to a table from the front-end, so I was looking for a better way to handle this.

The use case:

I am making an app with a determination table. The user can fill out details of the animal/plant (for example leaf shape) and is supposed to end at the right species.

I want to make it future proof, so that if someone fills out all details and the species they have is not the one the table comes up with, the user can add both their species, and the detail that would tell both species apart.

For example: if the user found a daisy but the table comes up with dandelion, the user could add the daisy and add ‘petal colour’ as a distinquishing feature.

Users should then be able to fill out the petal colour for all plants that were already in the database.

My database at the moment:

I have one table where all details (like species name, leaf shape etc.) are stored in columns.

My webiste: I use angular 7 for the front-end, PHP on the server and a MySQL database, but general answers are also very welcome.

Frontend. Как реализовать блок?

Нужно чтобы при нажатии на цифры, выделенные красным, менялся контент, выделенный зеленым. Только начинаю свой путь в верстке, подскажите с помощью чего (какого языка или конструкции) можно реализовать? Если у кого есть пример похожий, тоже с радостью посмотрю. введите сюда описание изображения