Question : How do I handle javascripts?

Permalink Browser Info Environment
Hello, Ramon.

I have a question for using javascript.

I put some javascript in a directory (/js).

What shoud I do then ?

Put code in Header of Elements tab
or use Custom Asset ?


Kind regards,

Ramon

Type: Discussion
Status: Resolved
BeSharp
View Replies:
ramonleenders replied on at Permalink Reply
ramonleenders
Hi there,

You can have that in your header or footer element, mostly it's in the footer though. See this part of the tutorial video

https://youtu.be/BsefTwqZQAo?t=6m40s...

You'll see at 7:15 that all the scripts are right above the </body> tag. They just point towards the "js" directory, if that's how your JavaScript directory is called within your assets (.zip file).

Kind regards,

Ramon
BeSharp replied on at Permalink Reply
BeSharp
Hello, Ramon.

Thank you for your reply.

I already watched your instruction videoa and follow your instruction.
But I don't have a good result.

What I did so far,
1. Tab(Elements)
Set Header(css) and Footer(javascript) and made a theme.

2. This result
This theme had proper css path and looked good in browser.
But javascripts did not work, so I checked HTML file.
I found no path to a js-directory.

3. I change Header to include link to javascripts.
But I got nothing changed.

4. So I put PHP code (to set path to theme) to javascript-links.
Scripts loaded but edit menu did not show up.

5. Then I decided to ask you a question.

6. (Now) Then I re-entry Header(css) and Footer(javascript).
This time, css and javascript, both don't have proper paths.
No code changed.

According to file time stamp, php files are re-build.
I checked Professionals tab,
Delete all existing theme files with the entered handle : YES
Do not edit my Elements and pagetamplates by default : YES

Do I have to reset or forget to do something else?


Kind regards,

BeSharp
ramonleenders replied on at Permalink Reply
ramonleenders
What does your browser say, where they pointing to? Also, what are your URL's for the JavaScript files? Can you send me the contents of the config.json file inside your package?
BeSharp replied on at Permalink Reply
BeSharp
Can I send you files with PM?
ramonleenders replied on at Permalink Reply
ramonleenders
Yes you can.
ramonleenders replied on at Permalink Reply
ramonleenders
You can do 2 things.

1) Go to "Assets" tab, click "Register Assets" and set "jquery" to "Provide";
2) Remove this line in footer (footer.php) element: <script src="js/jquery-2.1.4.min.js"></script>

Both should work. But I think the number 2 is better, because that means you still use the concrete5 jQuery and that means your Dashboard will never break (using different versions may cause troubles).

Let me know how that worked out.
BeSharp replied on at Permalink Reply
BeSharp
Hello, Ramon.

Thank you for your reply.

I remove the line in footer: <script src="js/jquery-2.1.4.min.js"></script>

Nothing changed for edit menu.
BTW, when I access "index.php/login", edit menu appears.

So making this problem clear, I removed all <script>tag from footer.
But nothing changed for edit menu, and css paths not added.

Kind regards,

BeSharp
ramonleenders replied on at Permalink Reply
ramonleenders
OK, you set this value:

"Do not edit my Elements and Page Templates by default "

To "Yes -- Ignore my elements"

That will not change your elements, and therefore not add the theme path in front of your CSS/Javascript etc. So set this value back to "No" and only set

"Delete all existing theme files with the entered handle"

To "Yes" if you want to recreate the theme.
BeSharp replied on at Permalink Reply
BeSharp
Hello, Ramon.

Thank you for your reply.

<What I did>
"Do not edit my Elements and Page Templates by default " : "No"
"Delete all existing theme files with the entered handle" : "Yes"

<Result -- good>
Edit menu appears. (This is a problem with theme itself.)
Javascripts have proper paths. ("footer.php" has proper codes.)

Thank you for your advise.

<New two questions>
1. (What is a difference between "Inspect theme" and "Load configration" in config?)
Codes in "Default Elements -> Footer"

"Inspect theme"
<script src="<?php echo $view->getThemePath()?>/js/scripts.js"></script>

"<Load configration>"
<script src="js/scripts.js"></script>


Codes in "Default Elements -> Header"

"Inspect theme"
<link rel='stylesheet' href='<?php echo $view->getThemePath()?>/css/custom.css'>

"<Load configration>"
<link rel='stylesheet' href='<?php echo $view->getThemePath()?>/css/custom.css'>


But both have "<?php defined('C5_EXECUTE') or die("Access Denied."); ?>" in first line.
So I mis-understood that rebuilt fail.
I thought that there were no diference. So I use two mixed, and made theme.
Wouid you please tell me, work flow to make
initial making,
re-building,
re-using existing themes.

ps. everytime makes theme, default.php is added
<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<?php $this->inc('elements/header.php'); ?>
<?php $this->inc('elements/footer.php'); ?>


2. (What are included in my elements ?)
There are many "No" options. Are they act same or different or not yet implemented?
Can I rebuild theme without changing some of my elements ?


Kind regards,

BeSharp
ramonleenders replied on at Permalink Reply
ramonleenders
Hi there,

See this page for your answers:

https://www.concrete5.org/marketplace/addons/theme-designer/question...

By setting the "Do not edit my Elements and Page Templates by default" to "Yes", it will not add the <?php echo $view->getThemePath()?> bit. So that's why there's a difference. It will also not add the <?php defined('C5_EXECUTE') or die("Access Denied."); ?>. That's why this field should always be at the "No" value. That way you can let the Add-On do the work for you. And in case any changes will be made within concrete5 in the future, this Add-On can fix that too. If you add it manually, there's nothing the Add-On can do. Also better if you don't have to do it yourself, it will mean there's less for you to worry about and less for you to look at when loading the configuration back in.

Kind regards,

Ramon
BeSharp replied on at Permalink Reply
BeSharp
Hello, Ramon.

Thank you for your reply and write FAQs.

It is getting clear how to use this add-on.
But it looks like I need more experience to use this tool.

At first, I will use this add-on as a theme skelton maker.
(It is also help me very much.)

Thank you for your help.

Kind regards,

BeSharp
ramonleenders replied on at Permalink Reply
ramonleenders
You will get there. You already know the basics and it's just a matter of time to get to know all the more advanced (experienced) options that are available.

Good luck creating themes! :)

concrete5 Environment Information

Concrete 5 8.1.0

Browser User-Agent String

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.