Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have already made a HTML page named Phaser.html, and use Javascript and the game framework Phaser.
Now i want to show this page in my silverstripe site. But i'm new in this and relly dont know how to do it, i just see php code, but i wanna just put my files in someweree and then linked to the page.
Another thing, When i add from the CMS, this show me a text editor like word. I should write code in there?.
Im using the simple theme. And i have already a structure of my site.
This is the phaser.html and the silverstripe page
I want to put the page on the left in my Silverstripe site.
Without actually seeing your code, this is going to be a shot in the dark, but perhaps try this:
Put your javascript code into a file named phaser.js. You said all of the code was javascript so a .html file shouldn't even been needed at all.
Copy that file into the mysite/javascript
Edit mysite/code/Page.php
Insert Requirements::js('mysite/javscript/phaser.js'); into the init() function so it looks like this:
public function init() {
parent::init();
Requirements::javascript("site/javascript/phaser.js");
}
Refresh the page and the javascript file should be now loaded as it should now be referenced inside the <head> tag.
Once you get that working I'd recommend taking the next step of creating your own Phaser_Page class that extends Page and move the Requirements call to that page and possibly create a custom template for your new page. How to do all that should be covered in the SilverStripe Lessons.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to create a video slideshow from scratch for my webpage.
Instead of displaying the videos directly I've managed so far to write a code using JavaScript which takes a YouTube video URL and takes its thumbnail to show it on the slideshow and here goes the problem:
The URL from the video has to be stored somewhere so the script can work properly, I've been hiding the URL inside the HTML code using the "src" attribute but that means I'll have to change it directly in the HTML code every time I want to display a different video on the slideshow.
I was thinking using a database (SQL) to store the URLs, but I read that linking JS/HTML and SQL is a bad practice and brings up unnecessary issues and will bring a headache and not a solution. So where or what can I use to store those URLs and link them properly into my code?
A database is the right answer, however, for just links, you may not want SQL. I would suggest JSON, but that may not even be necessary here. You can load an array of links from an external JS file. The contents of it would be:
var youtubeLinks = [
'https://youtube.com/link1',
'https://youtube.com/link2',
'https://youtube.com/link3'
];
If that file was called script.js and it was stored in your website root, then you can load it into your HTML as such:
<script src="script.js"></script>
Then in your javascript code that you already wrote, you can pass each link through a loop. Maybe something like this:
for (var i = 0; i < youtubeLinks.length; i++) {
thisLink = youtubeLinks[i];
// your code here
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
As a disclaimer, I'm quite new to web development and even before I posted this, I have spent hours looking for answers but everything I have read did not help on what I want to do.
I'm basically trying to redirect to a certain page and then execute a php function which also require a variable to be pass to it and is inside a class.
I've read about ajax but people have said that theres no point using it if I want to redirect to another page anyway as its only good to use if you just want to reload a portion of the page.
The most simplistic way I can explain on what I want to do is, when I click on an image, I would like for a new page to be open and then in that said page is all the things about that image. For example, description about it, a short vid and maybe a comment section regarding the image clicked.
Please explain if what I'm trying to do is not possible and if so, please point me in the right direction as to what might be a better way of doing this.
You can just link to a php page and pass a request variable.
Link
// myPage.php
<?php echo($_REQUEST['someVar']); ?>
This will output "someValue" on the new page.
here's a really simple example:`
<img src="test_image.png" alt="your alt"> <!-- Simple link with a id attribute -->
`
On the PHP side:
image_infos($_GET['id']); //Call the PHP function with the image ID
function image_infos($id)
{
//Get your infos from the Server or whatever
}
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I was wondering how to efficiently maintain a navigation bar. Based on my understanding right now, we just include the html code for the bar at each individual webpage. However, if I had many webpages I would need copy and rewrite the html code for each page. And if I would want to add or remove links I would need to change and update all of the pages. Is there a more efficient way to do this?
There are a lot of ways we can achieved this but here are the simplest I can think of right now.
1. Using PHP include_once function
You can use php for that. Simply store your navigation in a file called header.php for example, then include_once('header.php'); in your page. Make sure your page have a .php extension instead of .html
2. Using jQuery
If you want to stay with the current language(HTML,CSS,Javascript), you can also use JQuery load function.
$("#header").load('header.html');
It is better to run this after the DOM is ready:
$(document).ready(function() {
$("#header").load('header.html');
}
Somewhere in your code, you should have <div id="header"> for the script to inject the nav in header.html
what they do is that they load the page which is called from the server, besides the navigation bar. like either you can call the page in an iframe or you can run a script that could render the elements besides the navigation bar. That's how they could maintain the navigation bar
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Right now I have a simple website that looks something like this.
http://i.imgur.com/opllm1Y.png
I need a way to change the image and the description at the same time but keep the navbar and title the same as I do not want 100s of pages on for my website.
Would it be best to put image url's into a database and call it out with php along with the description?
Or is there another way to do it.
Does your content need to change without leaving the page?
If so, look into using jQuery and AJAX.
goto jQuery offical web site, and download the javascript file from them, then upload it to your server.
just before the closing tag for body, insert this:
<script src="your.jquery.file.js" type="text/javascript" ></script>
Now, on your page, a simple way to do this is make sure your img and div tags have id's:
<img id="image_to_change src="start.png">
<div id="text_content"></div>
After the script tag you included, use another script tag, this time, we're gonna put some javascript of our own in here
<script type="text/javascript">
$(document).ready(function(){
$('#image_to_change').onclick(function(){
$('#image_to_change').attr('src', 'next_image.png');
$('#text_content').text("The text you want to insert");
});
});
</script>
This of course is very crude, but it should give you a good starting point.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is there a way to create page turner effect for PDF files with angular? Jquery solutions are also fine. I have seen turn.js which uses html. Can any one help out to find a way for PDF files?
If you are talking about the pages within a PDF having a page curl effect then it is not something you can do with js, html or anything else outside the PDF itself without converting the PDF to something else (ie flash, jpg images, etc).
Last time I checked the only way to achieve this within a PDF was by using Acrobat Pro or InDesign and using 'Page Transitions'.
Please note that out of the available page transitions 'Page Turn' (the curl effect you want) will cause the document to be converted to a flash file and then embedded in the PDF.
I'm sorry if this is not what you want to hear. Rather than creating fancy page curl/turn effects it is probably better to concentrate on producing a well designed, easy to navigate document with great content. This will provide much better value.