Jump to content

RockFrontend πŸš€πŸš€ The Powerful Toolbox for ProcessWire Frontend Development


bernhard

Recommended Posts

15 hours ago, bernhard said:

RockFrontend does really not care what you output. But if you have troubles with latte files you can still include PHP files from your latte templates:

Β 

I know. My question was more in the direction if LATTE allows to execute somehow native PHP code. the LATTE tags "PHP" or "DO" donΒ΄t really seems to do the job, at least no output is generated when using those. I would like to avoid creating a new PHP file which I need to include, just to run one line of code.Β 

Link to comment
Share on other sites

14 minutes ago, maetmar said:

I would like to avoid creating a new PHP file which I need to include, just to run one line of code.Β 

I'm not sure, but i think you can set a variable and output it with latte (untested)
( {do} -> Executes the code and does not print anything )

{do $content = 20+10 }
{$content}
Link to comment
Share on other sites

By default LATTE echos the output that you put in { }

{$foo = 'FOO!'}

That would assign 'FOO!' to the $foo variable and as it is in { } output that.

{do $foo = 'FOO!'}

That would only assign 'FOO!' to the $foo variable and not output anything.

If you want to run more complex code it's always good to have an MVC-like approach with custom page classes, then you could do for example:

{$page->doFoo()}

Β 

  • Like 1
Link to comment
Share on other sites

I got the Formbuilder working now with LATTE.

Actually this works fine with latte: {$form}Β 

the problem was that I had to put this code into my _init.php: <?php $form = $forms->render('kontaktformular'); ?>

in the documentation of the formbuilder it says put it in _init.php or on top of your template file.
Firs,Β I put on top of my template file, which did not work, only after putting it into the _init.php it started producing output. But obviously also what Bernhard suggested worked fine.

Link to comment
Share on other sites

Hi @bernhard,Β 

I found an issue with the livereload feature. When enabled, I get the following error message in chrome development console:

"EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection."

https://stackoverflow.com/questions/53591954/eventsources-response-has-a-mime-type-text-html-that-is-not-text-event-str

It is reproducable, as soon as livereload is turned off, the error message is gone.
The message is not causing any issues, as far as I can tell, but I was spending now a lot of time just to find out it was caused by livereload.
So maybe you can check and make sure it gets fixed.

  • Like 1
Link to comment
Share on other sites

5 minutes ago, maetmar said:

It is reproducable

Then it would be nice to get a step by step guide to reproduce it πŸ˜‰Β 

I've seen that error here and then but don't know when it occurs or why. And a simple reload fixes it.

This error does cause issues, because if it occurs then livereload is not working (since it needs the eventstream to work). So if you find anything helpful I'm happy to improve that piece of rockfrontend.

  • Like 1
Link to comment
Share on other sites

On 11/16/2022 at 3:36 PM, bernhard said:

Then it would be nice to get a step by step guide to reproduce it πŸ˜‰Β 

I've seen that error here and then but don't know when it occurs or why. And a simple reload fixes it.

This error does cause issues, because if it occurs then livereload is not working (since it needs the eventstream to work). So if you find anything helpful I'm happy to improve that piece of rockfrontend.

this is what I was able to find out, I hope it helps

if an admin is loged in the backend and you have another tab open with the frontend --> no issue

if an admin is loged in the backend and you have another inqognito window open with frontend --> error

if no one is loged intp the backend and you have any session open with frontend --> error

Link to comment
Share on other sites

Hey @bernhard, as you have recently released the ScssΒ module, are there any plans to add SCSS compilation capabilities (if the module is installed) to RockFrontend as well? I'd love to be able to recompile Bootstrap automatically whenever files have changed and as this logic is already present in RockFrontend, this looks like a perfect addition to me. If you consider it, it would be great to be able to pass options to the compiler.

Cheers,
Flo

Link to comment
Share on other sites

Sure @snckΒ that sounds like a great addition. I'm not using Scss at the moment though so I'd be happy if you can provide a PR maybe?

The magic happens here:Β https://github.com/baumrock/RockFrontend/blob/e1ba2acb58967fe0cdf7cdc890b54870c5935082/StylesArray.php#L182

So we could just add another line below:

$this->parseScssFiles($opt);

You'd just need to implement that method based on the parseLessFiles() method πŸ™‚Β 

  • Like 1
Link to comment
Share on other sites

@bernhard, still the same behaviour.

I get the error whenever I am not loged into the backend or I open whenever I open the page in anΒ incognito browser window (tested with chrome).

When I am loged in and view the frontend in another tab it works fine.

I tried it on two different installations of processwire and both have the same behaviour.

ItΒ΄s not a big issue, as I use livereload anyway only during develoment of a new site and it should anyway be turned off once the page is live.

  • Like 1
Link to comment
Share on other sites

1 hour ago, maetmar said:

I get the error whenever I am not loged into the backend or I open whenever I open the page in anΒ incognito browser window (tested with chrome).

Sorry. I can't reproduce thatΒ πŸ€·β€β™‚οΈ

Link to comment
Share on other sites

Hi @bernhard, Any idea why I am getting this error in the dev tools console after installing the latest version?

Uncaught ReferenceError: RockFrontend is not defined
Β  Β  at RockFrontend.js?m=1660203134:11:12
Β  Β  at RockFrontend.js?m=1660203134:48:3

I updated from an earlier version (I forget which, but about 2 months ago) because font-awsome was not loading properly - I was gettingΒ 

<link rel="stylesheet" href="undefinedwire/templates-admin/styles/font-awesome/css/font-awesome.min.css" type="text/css">

rather than the correct url. Now I don't even get that link. Looks like a similar issue though as the url is given byΒ RockFrontend.rootUrl

Link to comment
Share on other sites

v2.9.0 adds support for rfShrink() 😍

div {
	border: rfShrink(20px, 5px) solid red;
}

which means 20px border @ 375px viewport and 5px border @ 1440px viewport and fluid in between.

div {
	border: rfShrink(20px, 5px, 600, 1000) solid red;
}

20px@600 / 5px@1000

  • Like 2
Link to comment
Share on other sites

On 11/29/2022 at 8:28 AM, bernhard said:

there is no RockFrontend.js file any more in the new version. Maybe just remove it from the scripts() array?

Thanks @bernhard. I did that, but I still get this:

Alfred.js?m=1660123300:179 Uncaught ReferenceError: RockFrontend is not defined
Β  Β  at Alfred.js?m=1660123300:179:3
Β  Β  at Alfred.js?m=1660123300:282:3
livereload.js?m=1660123300:11 Uncaught ReferenceError: RockFrontend is not defined
Β  Β  at startStream (livereload.js?m=1660123300:11:14)
Β  Β  at livereload.js?m=1660123300:47:3

Link to comment
Share on other sites

4 hours ago, bernhard said:

It looks like either that hook is not triggered or you are maybe using another hook that overwrites/replaces that hook?

The hook seems to be working OK. RockFrontend is a js variable. Where is it supposed to be set?

Link to comment
Share on other sites

Thanks @bernhard. I can see in the dev tools elements that (for example)

<script>let RockFrontend = {"rootUrl":"\/","defaultVspaceScale":0.66000000000000003}</script>

is added, but the error persists. Also, I note that this script is not added if there is no Alfred tag on the page, so will that not always cause an error in Alfred.js (albeit not important)?

Link to comment
Share on other sites

13 hours ago, MarkE said:

is added, but the error persists. Also, I note that this script is not added if there is no Alfred tag on the page, so will that not always cause an error in Alfred.js (albeit not important)?

Is Alfred.js somehow loaded before RockFrontend is defined? It should be loaded after that of course.

I don't think that is a problem. If no Alfred tag is on the page, then also Alfred.js is not loaded and therefore there should not be an error.

Are you maybe loading Alfred.js manually?

Link to comment
Share on other sites

44 minutes ago, bernhard said:

Are you maybe loading Alfred.js manually?

Aha! I haveΒ 

	<script src="<?= urls()->siteModules?>RockFrontend/Alfred.js?m=1660123300"></script>
	<script src="<?= urls()->siteModules?>RockFrontend/livereload.js?m=1660123300"></script>

in my head. I think that was maybe the requirement with an earlier version but no longer needed?

Link to comment
Share on other sites

  • bernhard changed the title to RockFrontend πŸš€πŸš€ The Powerful Toolbox for ProcessWire Frontend Development

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
Γ—
Γ—
  • Create New...