Closed JoshuaKimsey closed 7 years ago
I used to use dreamweaver code view - but it felt wasteful as 99% of dreamweaver I don't use, the code view was outstanding though for php & html. I tried various others & currently use Visual Studio Code. Before that I used Komodo Edit, which is decent but I found it a bit buggy.
Sorry I havent had time to look at your other comments recently, been busy. Ive been building a new racing quad & that eats all my spare time ;-)
Ah ok! I know about DreamWeaver, and I also know the hate that it receives. However, that would be an option, assuming I don't have to shell out massive amounts of money for it. Cause I know the full version of DreamWeaver used to cost a fortune. In an ironic twist, I was going to say that Visual Studio wasn't available for Mac, but I just saw an ad on Twitter saying a Mac version was now available, so I'm gonna give that a try! I also downloaded Komodo Edit, and while it seems ok, it seems to be lacking significantly in features. Like, it's literally no better than my current setup of using Brackets to code, CodeRunner 2 to debug PHP (sorta), and Opera to run the code. I think VS might be the key I was looking for, but I'll let ya know shortly!
No worries man! That's epic that you build your own race cars!
I use a Mac too. Racing quad, I mean quadcopter aka drone racing ;-) https://youtu.be/LGkquygJipY
Oh dude! That's amazing! Holy crap, I'm totally envious now! 😄 Did you build the whole thing from scratch?
Built from scratch yes but using various parts, motors, carbon frame, flight controller. soldering stuff together. first build was a big learning process. its like 2 hobbies in one. the electronics & building side & then the flying side!
That's awesome man! That must have been a feat the first time you successfully test flied your drone! I'm assuming Japan doesn't have any restrictions on Drone usage? (Cause you'd be in deep doo-doo over here if you didn't register your drone with the gov, follow a bunch of restrictions, blah, blah, blah!)
Ok, I installed VS code, and it seems to run great! I like the interface a lot! However, it still can't help me solve my issue, so hopefully you'll be able to help. In order to know what the current weather conditions are, to set the dynamic background, I wanted to use PHP to capture from the index.php file, or the stream file, what the currently used svg icon was. I figured this would be an easy way of determining that and setting the background image accordingly. However, it has turned into a massive headache. No matter what I have tried, which is rather limited due to my rather small knowledge of PHP, I have been unable to read the HTML code from the index file. I thought it'd be as easy as implementing the same code used to capture the alert-warnings from Wunderground, but that system has failed to work. So my question is, how to I read HTML code from a another file and have that integrate into the php function I am trying to implement.
Here's the function I was trying to create. Note that the "index.php" is hardset for now, although that is easily changeable to work with any file the function is used in, namely the companion stream.php file.
//Pull the appropriate data from the current weather area and displays the appropriate background
function dynamic_background() {
$file=file_get_contents("index.php");
preg_match_all("%<div class=\"weathericon(.*?)</div>%s", $file, $weatherArray, PREG_PATTERN_ORDER);
$current_weather = $weatherArray[0][0];
return $current_weather;
}
Hi J95, file_get_contents is no good in this situation, its only for getting pages or files from another location, not getting your own content. The way to do this is to look at weather.js & add something to re-use the same weathericon#. So basically when it inserts weathericon20.png we need to add something that also adds "background20.jpg" into some inline css on the DIV.
I had a very quick look at it, but not in detail, but im sure this is the way to do it.
in the weather.js
$(".location").text(city);
$(".temperature").html(temp);
$(".climate_bg").html(wcode);
$(".windspeed").html(wind);
$(".humidity").text(humidity);
$(".updated").text(updated);
$(".forecast").html(iconcode);
These items insert some text or code into a html element with the same name So "$(".location").text(city);" put the CITY in as text into the element on index.php with the class="location"
What we need is to add a class name like "wbg20" into climate_bg OR at the top of weather.js
iconcode += '<span><img src="images/weathericons/' + fi[i] + '.svg" /><br />' + fd[i] + '</span>';
so we could change the SPAN there to a DIV & give it a class
I am about to go out but I can have a look this evening
Awesome! Thanks for this! I'll see if I can implement this tomorrow! I think using the JS code would definitely be easier than what I was gonna try and do with the PHP code.
Looks like this is the way to go!
success: function(weather) {
**bgclass = 'wbg' + weather.code;**
.....
$(".location").text(city);
**$(".climate_bg").addClass(bgclass);**
...
That worked! Thanks so much man! I'm now working on implementing the pictures into a working dynamic background. I'll go ahead and close this thread!
Hey man, I was wondering if you could refer me to a good IDE to use for PHP development? Up until now, I have sorta just been winging it with a normal web IDE and just refreshing my browser to see if something works. However, it's becoming increasingly difficult to see what is happening with the PHP code I'm trying to develop. Do you use, or know of, a good IDE that would work well for an integrated environment with PHP and HTML?