Webmasters Discussion / Lounge Page 2

Started by Tsutarja August 16th, 2012 9:29 PM
  • 8000 views
  • 64 replies
Male
Seen November 6th, 2020
Posted May 17th, 2013
467 posts
11.3 Years
The two most common ways to get PHP data into JavaScript is to either:

a) Use AJAX with a PHP file that spits out JSON with json_encode(). For example:
<?php
// Some code that sets $var to the desired value or array.
echo json_encode($var);
?>
Then use JSON.parse to parse your JSON into a usable JavaScript variable.

OR...
b) Echo JavaScript-usable data into the page... For example:

<script type='text/javascript'>
  var somevar = <?php echo $var; ?>;
</script>
Be very careful with this approach though since it is very vulnerable to XSS. (Imagine if $var is set to "4; alert('Hi!');" for example...)

For JavaScript to PHP, since PHP is server-side, this requires server activity. You'll either need to use AJAX or reload your current page with the GET or POST variables you want. GET variables are easy since you can fire an AJAX request to someurl?var=<someval>&anothervar=<someothervar>.

droomph

weeb

Age 26
Male
nowhere spectacular
Seen February 1st, 2017
Posted January 3rd, 2017
4,282 posts
11.7 Years
The two most common ways to get PHP data into JavaScript is to either:

a) Use AJAX with a PHP file that spits out JSON with json_encode(). For example:
<?php
// Some code that sets $var to the desired value or array.
echo json_encode($var);
?>
Then use JSON.parse to parse your JSON into a usable JavaScript variable.

OR...
b) Echo JavaScript-usable data into the page... For example:

<script type='text/javascript'>
  var somevar = <?php echo $var; ?>;
</script>
Be very careful with this approach though since it is very vulnerable to XSS. (Imagine if $var is set to "4; alert('Hi!');" for example...)

For JavaScript to PHP, since PHP is server-side, this requires server activity. You'll either need to use AJAX or reload your current page with the GET or POST variables you want. GET variables are easy since you can fire an AJAX request to someurl?var=<someval>&anothervar=<someothervar>.
hehe thanks :p that makes it a lot clearer

Soooooooo I'm trying to implement a whissiwig editor or whatever it's called onto my website, and I have with the tinyMCE program…

however one problem is that it takes a long time to load, much worse than the one on PC, but I suppose because it's not WYSIWYG, so…

1) how to make it load faster, or 2) what other better options do I have?

sorry for asking and not telling, but I'm a noob at this :p
did u no there r 21 letters in the alphabet
o i forgot 5
uraqt


Male
Seen November 6th, 2020
Posted May 17th, 2013
467 posts
11.3 Years
hehe thanks :p that makes it a lot clearer

Soooooooo I'm trying to implement a whissiwig editor or whatever it's called onto my website, and I have with the tinyMCE program…

however one problem is that it takes a long time to load, much worse than the one on PC, but I suppose because it's not WYSIWYG, so…

1) how to make it load faster, or 2) what other better options do I have?

sorry for asking and not telling, but I'm a noob at this :p
Are you familiar with your browser's web-inspector network tab? Because it is a great asset when checking to see why pages load slowly.

This is the network inspector tab in Opera Dragonfly...
Spoiler:


As you can see, it shows how long each request and response took, and if you mose over the bars, you can see a breakdown of what process took what amount of time:
Spoiler:


If something takes a long time, you can try to utilize caching, which will, instead of sending all of the data to a computer that has downloaded it again, send a simple 304 to the browser to indicate that it hasn't been modified:
Spoiler:


As you can see, this cuts down the amount of time a browser needs to download anything A LOT.
Spoiler:


If you have access to the configuration of your server, you can set it to use aggressive caching by sending an "Expiry" header with it's responses to allow data to be cached to make your site seem blazing fast, even if it uses exuberant AJAX and styles.

You can find out how to utilize the Expires header here.

Yahoo has some good guidelines too: http://developer.yahoo.com/performance/rules.html#expires

MKGirlism

3DS and Wii U Game Developer

Age 31
Female
Netherlands
Seen January 15th, 2015
Posted October 19th, 2014
414 posts
10.3 Years
I've made my own CMS, which I called "CWMSv4".
At the moment, it's not really intractable, but I'm planning on putting in more features people other than me and our Staff can use.
To rate it: http://www.cw-games.org

In addition, I'm using AcmlmBoardXD on my Blog/Forums.
While I love the Forum Software, I'm still not really used with Styling it.
Here's what I've made of:
http://www.mkgirlism.eu/?page=board
(It includes a Mobile Theme.)

Could you guys/gals give a Feedback for both?
~Yami

donavannj

Age 32
Male
'cause it get cold like Minnesota
Seen 5 Days Ago
Posted 1 Week Ago
22,513 posts
18.2 Years
cw-games.org thoughts and comments:
At this point, the website looks quite plain and very basic. You probably don't have a full-time staff to dedicate to it, but you need more visuals to make the site appear more enticing to the general public. The site does appear to meet the "get to where you want to go within 3 clicks" guideline for design quite well, though. That site's support forum is very basic and gives off quite the '90s forum vibe, and it is very hard to tell what's the actual post content and what's just information regarding the post or poster. The support forum has too much going on with each segment of a post being given its own visible border.


mkmgirlism.eu thoughts and comments:
Your forum's default style, while interesting, could use a few tweaks, including the pink drop-shadow behind all the text that has it. That drop-shadow makes it very difficult to read certain usernames. Actually, you may want to change the font-color of that group of usernames, as upon closer inspection it seems that it's the background color of the content areas of the forum that those usernames really clash with.
whoops

MKGirlism

3DS and Wii U Game Developer

Age 31
Female
Netherlands
Seen January 15th, 2015
Posted October 19th, 2014
414 posts
10.3 Years
As for the first site, the plain and basic look is on purpose, because it's meant to be as lightweight as possible.
After all, I don't want to create a MySpace-clone out of it.
The Support Forum is something I agree on, that's why I'm planning to focus my Updates fully on the Forum part.

For the second site, it's actually "MKGirlism", not "MKMGirlism" (it stands for Mario Kart Girl, by the way).
Though it's true the background colours, I didn't want to make it to pink or to blue, just something that's calm to the eyes.
Group names are indeed a concern, so I guess I'll check out what I can do with the colours, as it conflicts with the names if somebody is female (female users are pink, male users are blue, and people who didn't specify their gender are purple, in case you want to know that).
~Yami

Legendary Silke

You like dragons?

Seen December 23rd, 2021
Posted April 22nd, 2020
5,925 posts
12.5 Years
Finding out about Microsoft WebMatrix was a pleasant surprise. Turns out it's extremely easy to create, test, and publish entire sites when you have a proper web site editing/testing suite on your computer.

I particularly like IntelliSense and how extensible WebMatrix itself is. It didn't take too long for me to stop using Notepad++ and manual FTP uploads and move to something way more integrated - and less haphazard.

Bonus points for finally getting some PHP action in.

Now, I have to figure out what the heck is up with PHP includes on the other side... (I can't change the include paths.) I've went with somewhat harder paths for now. (things like /home/twigzone/public_html since I'm on shared virtual)

(By the way: what do you guys here think of ASP.NET? And on a related topic, how does one do something similar to ASP.NET layouts (automatically inserted boilerplate code in a page, like headers and footers) in PHP?)

By the way, perhaps this is a good time to check out my personal site.

MKGirlism

3DS and Wii U Game Developer

Age 31
Female
Netherlands
Seen January 15th, 2015
Posted October 19th, 2014
414 posts
10.3 Years
Paths being at /home/username/public_html has nothing to do with Shared Hosting or not, it's because your Hosting uses Linux.
The /home folder is equal to C:\Users on Windows Vista and newer.

To get the Include Paths, you'll use something like (yes, with a forward-slash, if you want to use a backslash, make sure you use it twice every time):
include("C:/Users/twigzone/blablabla/myfile.php");
Instead of:
include("/home/twigzone/public_html/myfile.php");
However, it can be much more efficient.
Let's assume the file you're editing right now is "index.php", and you want to include the file "myinclude.php" in the folder called "twiggy".
In that case, it's best to use:
include("twiggy/myinclude.php");
When using that, rather than using the full path, it'll save you from a lot of typing, and at the same time, it'll work on both, your Linux Hosting, and your Windows PC.
~Yami
Seen July 22nd, 2016
Posted July 22nd, 2016
900 posts
12.8 Years
I've had the same website now for the past few years and I think it's time to update it, specifically to make it more compatible with tablets.

Here is my site as it currently is: www.jasonfinigan.net

I am not interested in using Wordpress ... at all.

Paramaters:
  • Rotating banner upon page load
  • One column layout
  • Must be easily viewable on both a computer and a tablet

Any suggestions?
DAKOTAH
Personal Website
YouTube Channel


1693-4093-6753
Normal Safari
Lillipup / Audino / Ditto


"...many of the truths we cling to depend greatly on our own point of view." ~ Obi Wan Kenobi

Legendary Silke

You like dragons?

Seen December 23rd, 2021
Posted April 22nd, 2020
5,925 posts
12.5 Years
Paths being at /home/username/public_html has nothing to do with Shared Hosting or not, it's because your Hosting uses Linux.
The /home folder is equal to C:\Users on Windows Vista and newer.

To get the Include Paths, you'll use something like (yes, with a forward-slash, if you want to use a backslash, make sure you use it twice every time):
include("C:/Users/twigzone/blablabla/myfile.php");
Instead of:
include("/home/twigzone/public_html/myfile.php");
However, it can be much more efficient.
Let's assume the file you're editing right now is "index.php", and you want to include the file "myinclude.php" in the folder called "twiggy".
In that case, it's best to use:
include("twiggy/myinclude.php");
When using that, rather than using the full path, it'll save you from a lot of typing, and at the same time, it'll work on both, your Linux Hosting, and your Windows PC.
OK, let's see...

I'm going to use something like include("twigzone/myinclude.php"), right? There's a bit of a problem, though - on the IIS Express 8 server on the local machine, the site root is... / as far as the local server and PHP is concerned, even though the actual files are actually in, say, "C:\Users\Twiggy\Documents\My Web Sites\TwigZone\".

Looks like I'll have to take advantage of remote editing controls in WebMatrix while we figure out the solution of this.

MKGirlism

3DS and Wii U Game Developer

Age 31
Female
Netherlands
Seen January 15th, 2015
Posted October 19th, 2014
414 posts
10.3 Years
No, it really doesn't matter.
If you don't start the Path with a slash, it'll recognise the path as a your current folder.

Since, let's say, "index.php" is in "C:\Users\Twiggy\Documents\My Web Sites\TwigZone\", all you need to is "include("myinclude.php");", if "myinclude.php" is in the same folder.
If not, just add the folder name + slash + myinclude.php.

In my own CWMSv5 system, I'm using stuff like:
include("module/sitemap.php");
include("module/foot.php");
And I can use it on Windows and Linux with no problems.

I've had the same website now for the past few years and I think it's time to update it, specifically to make it more compatible with tablets.

Here is my site as it currently is: www.jasonfinigan.net

I am not interested in using Wordpress ... at all.

Paramaters:
  • Rotating banner upon page load
  • One column layout
  • Must be easily viewable on both a computer and a tablet

Any suggestions?
In my opinion, the third point already fits your wishes.
I agree WordPress can be to limited at times (that's why I've made my own CMS), but all you listed in the Parameters, can be done with WordPress too.

Legendary Silke

You like dragons?

Seen December 23rd, 2021
Posted April 22nd, 2020
5,925 posts
12.5 Years
No, it really doesn't matter.
If you don't start the Path with a slash, it'll recognise the path as a your current folder.

Since, let's say, "index.php" is in "C:\Users\Twiggy\Documents\My Web Sites\TwigZone\", all you need to is "include("myinclude.php");", if "myinclude.php" is in the same folder.
If not, just add the folder name + slash + myinclude.php.

In my own CWMSv5 system, I'm using stuff like:
include("module/sitemap.php");
include("module/foot.php");
And I can use it on Windows and Linux with no problems.
Looks like it worked like a charm. (Man, why did I not think about it earlier? xD)

perthskies

Nostalgic

Age 34
Male
Perth, Western Australia
Seen December 7th, 2013
Posted November 20th, 2013
339 posts
19.4 Years
Hello everyone, just wondering if I could get your opinion on my Digimon Frontier fansite:
http://tdfn.ancommunity.net/

I know this is a Pokémon community but a Pokémon fansite is coming soon! xD I've had this fansite since 2003 and it was looking dated with the old PHP includes so I gave it a WordPress makeover.

Would be keen to get feedback specifically on:
  • Loading times (it is fairly graphic intensive and the theme I purchased seems to have AJAX loading)
  • Legibility (background images in place)

Any feedback would greatly be appreciated!



Also known as: Optic
My Anime Fansites | Forums
Seen July 22nd, 2016
Posted July 22nd, 2016
900 posts
12.8 Years
In my opinion, the third point already fits your wishes.
I agree WordPress can be to limited at times (that's why I've made my own CMS), but all you listed in the Parameters, can be done with WordPress too.
Does the lytebox work alright with tablets? I know some of them have had issues with javascript coding (especially with drop down menus).

Also, with regards to Wordpress, my main complaint with it is that the more applications you add to the thing, the slower and more cumbersome it becomes. I've seen some Wordpress sites where I could actually go grab a cup of hot chocolate before the site even loads!

But mainly, I'm asking for ideas to change the website because I think it's time to change the look. Having the same website for too long can become boring to people. The problem is, most of the templates I've seen so far don't really appeal to me.
DAKOTAH
Personal Website
YouTube Channel


1693-4093-6753
Normal Safari
Lillipup / Audino / Ditto


"...many of the truths we cling to depend greatly on our own point of view." ~ Obi Wan Kenobi

perthskies

Nostalgic

Age 34
Male
Perth, Western Australia
Seen December 7th, 2013
Posted November 20th, 2013
339 posts
19.4 Years
But mainly, I'm asking for ideas to change the website because I think it's time to change the look. Having the same website for too long can become boring to people. The problem is, most of the templates I've seen so far don't really appeal to me.
Hello Jay,

I looked at your site and I thought it was a nice clean layout. :) If you're thinking of a fresh look perhaps you could consider incorporating your high resolution wallpapers (Destiny's Edge & The Enemy Within) as part of the layout as a background image?

Something along the lines of this as an example: (though text legibility would take a hit)
http://www.agdinteractive.com/games/kq2/about/about.html

Or maybe some background textures like this:
http://www.agdinteractive.com/games/kq3/behindscenes/selwood.html

Bear in mind I'm more biased towards graphic heavy layouts/looks which may not appeal to you.. maybe the others would have ideas if you prefer a more clean/crisp layout?



Also known as: Optic
My Anime Fansites | Forums

Legendary Silke

You like dragons?

Seen December 23rd, 2021
Posted April 22nd, 2020
5,925 posts
12.5 Years
I'm interested in using web fonts as a fall-back font for situations where Segoe UI is not available.

(Site in question: TwigZone)

1. What is a good web font service?
2. What should I go with without going too far away from Segoe UI?

perthskies

Nostalgic

Age 34
Male
Perth, Western Australia
Seen December 7th, 2013
Posted November 20th, 2013
339 posts
19.4 Years
Hello Twiggy,

1. I love Google Fonts, they have a nice range and it's free! Very straightforward to use too, just embed their stylesheet after you pick a font you're happy with and reference it in your CSS.

2. That's a tough call - I think Open Sans looks pretty close (it's also the font I'm using for my fansites, I really like it!) :)



Also known as: Optic
My Anime Fansites | Forums

MKGirlism

3DS and Wii U Game Developer

Age 31
Female
Netherlands
Seen January 15th, 2015
Posted October 19th, 2014
414 posts
10.3 Years
Remember, green is a very sensitive colour, and I can feel it too (ouch!).
Anyway, you could use Fonts via CSS, so you won't need to worry about what the visitor has installed on their PC.

For example:
<html>
<style>
@font-face {
    font-family: 'Symbola';
    src: url('Symbola.eot');
    src: local('Symbola'),
         local('Symbola'),
         url('Symbola.ttf') format('truetype'),
         url('Symbola.svg#font') format('svg');
}

.Symbola {
	font-family:Symbola;
}
</style>
<body>
<div class="Symbola">This is a test.</div>
</body>
</html>
~Yami

Tsutarja

Age 28
he / him
Florida
Seen 6 Hours Ago
Posted 15 Hours Ago
27,327 posts
13.2 Years
I haven't done my own @font-face in stylesheets before, but if you need to get a font for your website but don't want to go through the hassle of programming it into a stylesheet manually, then I really recommend this web font generator from fontsquirrel.com (which is really for anyone as a reference), but I'm sure that you wouldn't have any trouble :)

Legendary Silke

You like dragons?

Seen December 23rd, 2021
Posted April 22nd, 2020
5,925 posts
12.5 Years
I've went with locally hosted Open Sans and Droid Sans Mono as the fall-back fonts for when Segoe UI and Consolas are missing. Thank goodness Font Squirrel exists, huh?

Looks pretty fine from what I've been using. Microsoft WebMatrix really does make testing really easy and rapid.

MKGirlism

3DS and Wii U Game Developer

Age 31
Female
Netherlands
Seen January 15th, 2015
Posted October 19th, 2014
414 posts
10.3 Years
I haven't done my own @font-face in stylesheets before, but if you need to get a font for your website but don't want to go through the hassle of programming it into a stylesheet manually, then I really recommend this web font generator from fontsquirrel.com (which is really for anyone as a reference), but I'm sure that you wouldn't have any trouble :)
Come on, the @font-face method really isn't hard at all!

Legendary Silke

You like dragons?

Seen December 23rd, 2021
Posted April 22nd, 2020
5,925 posts
12.5 Years
Come on, the @font-face method really isn't hard at all!
Indeed. As long as you know the bulletproof web font syntax, you should have no problems with compatibility.

I prefer to also define font styles and weights in a @font-face block as I prefer using the same font family name and using the "correct" weights using font-weight and font-style in the actual CSS.

You might fancy something like this:
@font-face {
    font-family: 'Open Sans'; /* Specify a global font name */
    font-weight: normal; /* Specify what "weight" (e.g. normal, bold, lighter) these files are for */
    font-style: normal; /* Specify what "style" (e.g. normal, italic) these files are for */
    
    src: url('/styles/fonts/opensans/opensans-regular.eot');
    src: url('/styles/fonts/opensans/opensans-regular.eot?iefix') format('eot'),
	     url('/styles/fonts/opensans/opensans-regular.woff') format('woff'),
	     url('/styles/fonts/opensans/opensans-regular.ttf') format('truetype'),
	     url('/styles/fonts/opensans/opensans-regular.svg#webfont') format('svg');
}

Tsutarja

Age 28
he / him
Florida
Seen 6 Hours Ago
Posted 15 Hours Ago
27,327 posts
13.2 Years
Come on, the @font-face method really isn't hard at all!
For the record, I have minimal experience with @font-face, so please watch at what you say. I respect your opinion for saying that it's not really hard at all, but keep in mind that experience level plays a role in what someone says about something.

Legendary Silke

You like dragons?

Seen December 23rd, 2021
Posted April 22nd, 2020
5,925 posts
12.5 Years
For the record, I have minimal experience with @font-face, so please watch at what you say. I respect your opinion for saying that it's not really hard at all, but keep in mind that experience level plays a role in what someone says about something.
Mmm, perhaps so, but you could certainly start out with the code block I've there. Just remember to replace all the URLs with where things are actually located on the server.

Speaking of web fonts and Google Fonts, I'm a bit... annoyed at the fact that Google Fonts API serves EOT fonts to Internet Explorer versions 9 and above even though IE9 supports WOFF and prefers it to everything else given a list of fonts to download in @font-face. (EOT doesn't support ligatures and other nice things that WOFF does.)

They had over two years...

Alexander Nicholi

work hard, play hard

Age 25
Male
Research Triangle / Jakarta
Seen February 15th, 2023
Posted March 5th, 2021
5,498 posts
13.5 Years
I'm running a VPS called Thunderbolt Networks with the following statistics:
Can you guys give me some suggestions for further improvement to the two sites' layouts? Both of them use a fixed background image that covers the screen, and I custom skinned the forums and modified the colors of an existing WordPress theme with a new background.

With the forum I'm also open to structural suggestions. :)
the beat goes on (ノ^o^;)ノ
ヽ(;^o^ヽ) the beat goes on
the beat goes on (ノ^o^;)ノ
ヽ(;^o^ヽ) the beat goes on
( don’t stop the groovin’ )