Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
Okay I still can't figure this out, how do you execute a function in an extended class to fill a variable?
simplified example
[code]
class square_dostuff extends sqaure {
var $sqaureName="doStuff";
var $squareID="doStuff";
var $squareIcon="icon-console";
var $squareSize="sqDub";
var $squareContent=doStuff();
function doStuff {
echo "do";
echo "stuff"
}
};
[/code]
[code]
class square_dostuff extends sqaure
{
public $sqaureName = 'doStuff';
public $squareID = 'doStuff';
public $squareIcon = 'icon-console';
public $squareSize = 'sqDub';
public $squareContent;
public function __construct()
{
$this->squareContent = $this->doStuff();
}
public function doStuff()
{
// implement views rather than just echoing here, but since you want to put the value into $this->squareContent then should return it instead.
return 'something';
}
};
[/code]
__construct is called on creation of an object.
Also tidied the code. The use of var is depreciated, public behaves the same, if you want the property or a method to be inaccessible from outside the class then use private.
Is there a snippet of code I can use to change an object's colour continuously at a set interval?
[QUOTE=MasterFen006;44174838]Is there a snippet of code I can use to change an object's colour continuously at a set interval?[/QUOTE]
JQuery with JQueryUI can be used for relatively easy colour animation.
There are also [URL="http://css-tricks.com/snippets/css/keyframe-animation-syntax/"]CSS3 animations[/URL].
I dont think variables should ever be public in a class. that's what oop is for.
[editline]8th March 2014[/editline]
also use the view part to print out what you want. never echo or print inside a php function
[QUOTE=jung3o;44175840]I dont think variables should ever be public in a class. that's what oop is for.
[editline]8th March 2014[/editline]
also use the view part to print out what you want. never echo or print inside a php function[/QUOTE]
If you were strictly adherent to OOP, then perhaps behaviors is all you would want to expose (i.e. methods), but getters/setters aren't exactly behaviors; if you are going to add a getter/setter anyway, then why not just expose the variable? Remember, YAGNI.
[code]class dick extends butt {
public function
}
[/code]:v:
so this is what I have right now
[img]http://i.imgur.com/qqDDhy4.png[/img]
and here is the documentation im looking at [url]http://laravel.com/docs/eloquent#relationships[/url]
do I use many to many?
So there are many vBanList that id from steamUser has and there is one item that connects to SteamUser that a vBanList communityId has.
This is the first time I'm doing this and I'm so confused :v:
That diagram looks like crud.
1 list should have many users and if you want another list just add that user to that list as well.
[QUOTE=01271;44184637]That diagram looks like crud.
1 list should have many users and if you want another list just add that user to that list as well.[/QUOTE]
yeah I should've just done that. thanks
How do I limit how many of one value can be in a single collection/table.
I want to have up to 100 or so of each value in a database.
So up to 100 "hi"
up to 100 "bye"
up to 100 "etc"
Should I just do it in mongodb and make a new collection for each value or should I do it in mysql and have your expertise(s) to rely on?
There are no numbers for item ids so I'll have to either assign every new item an unique ID and check it in the main table or just use the item names as the keys.
[img]http://i.imgur.com/0Cc2KbK.png[/img]
my current planned database layout where table names are the foreign keys so I can limit each table to 100 rows.
It seems to be appropriate to bring up Greasemonkey stuff in this forum.
I have a script that replaces text values (mins to minutes, why facebook).
Although, since facebook uses a ajax and never actually changes the page AND content is also loaded after pageload, I am unsure how I can reapply the text replace function after an ajax GET
How is page content [I]loaded as needed[/I] without refreshing?
I'm aware of the simplistic jQuery show/hide methods of doing this.
However all the implementations I've seen thus far assume that you don't mind loading the entire website but a single page as display:none
A good example is the new-ish red loading bar on YouTube when switching videos.
What is the[I] correct [/I]way to do this?
Just about every solution I've seen is either smoke and mirrors or loads data in a complex way via AJAX or sockets.
Is this the result of different languages such as node or ruby? (I completely don't know)
It seems like there are backend languages that talk to the frontend side of pages much better.
However this is my perception.
IE (Javascript doesn't talk to PHP)
What is the difference between
[code]
$(elemenelment).hide();
and
elemenelment.hide();
[/code]
?
What could cause encoding issues with PHP FTP script? Normal FTP transfer does not mess up accented characters and I sure all related PHP files are utf8 encoded. Somehow it seems to act like the filenames set by the script are latin1 and decides to convert them to utf8.
[QUOTE=lkymky;44189996]How is page content [I]loaded as needed[/I] without refreshing?
I'm aware of the simplistic jQuery show/hide methods of doing this.
However all the implementations I've seen thus far assume that you don't mind loading the entire website but a single page as display:none
A good example is the new-ish red loading bar on YouTube when switching videos.
What is the[I] correct [/I]way to do this?
Just about every solution I've seen is either smoke and mirrors or loads data in a complex way via AJAX or sockets.
Is this the result of different languages such as node or ruby? (I completely don't know)
It seems like there are backend languages that talk to the frontend side of pages much better.
However this is my perception.
IE (Javascript doesn't talk to PHP)[/QUOTE]
PHP can talk to JS just as well as node/ruby can. Generally you're going to be sending JSON to the client from the back-end, and that's an important enough thing to be able to do that all back-end web dev languages can speak JSON (although I would still prefer not to write my backend in php at all :P)
IMO, the correct way is...
1. Client requests the the new page
2. JS on the client requests JSON containing the data for the new page
3. Back-end responds with JSON (if you were asking for a user profile page, you'd send the username, their bio, the url for their avatar, etc)
4. JS on the client takes the data and sticks it in to the HTML
You [I]can[/I] also just send rendered HTML from the backend to the client and replace the html of the current page (or part of the current page), but you generally send less data over the wire if you're just sending the JSON and let the client figure out where stuff goes.
[editline]10th March 2014[/editline]
[QUOTE=Worre;44191360]What could cause encoding issues with PHP FTP script? Normal FTP transfer does not mess up accented characters and I sure all related PHP files are utf8 encoded. Somehow it seems to act like the filenames set by the script are latin1 and decides to convert them to utf8.[/QUOTE]
Make sure your FTP client is running in binary mode.
[QUOTE=KmartSqrl;44191708]-snip-
[editline]10th March 2014[/editline]
Make sure your FTP client is running in binary mode.[/QUOTE] Already tried both ascii and binary. The result is same on both modes.
Is anyone else getting 503 errors when connecting to the steam API via XML?
[QUOTE=KmartSqrl;44191708]PHP can talk to JS just as well as node/ruby can. Generally you're going to be sending JSON to the client from the back-end, and that's an important enough thing to be able to do that all back-end web dev languages can speak JSON (although I would still prefer not to write my backend in php at all :P)
IMO, the correct way is...
1. Client requests the the new page
2. JS on the client requests JSON containing the data for the new page
3. Back-end responds with JSON (if you were asking for a user profile page, you'd send the username, their bio, the url for their avatar, etc)
4. JS on the client takes the data and sticks it in to the HTML
You [I]can[/I] also just send rendered HTML from the backend to the client and replace the html of the current page (or part of the current page), but you generally send less data over the wire if you're just sending the JSON and let the client figure out where stuff goes.
[/QUOTE]
So this is more of the separate your unique content from your code stuff that cbastard was talking about. Only this time javascript keeps requesting data in the form of json and depending on its own logic; content is filled via JS?
That sounds like alot of javascript.
I was thinking that I would definitely have javascript do something like request a new page when a link is clicked, but is there an equivalent to PHP's include in JS that I could use?[I] (Yes I know that is an idiotic statement but you get my drift) [/I] If say I wanted to send at least portions of HTML across the net
Also KmartSqrl you are very knowledgeable about PHP despite you not advocating its use. I appreciate the directions :v:
[QUOTE=gokiyono;44190124]What is the difference between
[code]
$(elemenelment).hide();
and
elemenelment.hide();
[/code]
?[/QUOTE]
That depends on what 'elemenelement' is. If it is an HTMLElement or if it's a JQuery object. The second variable could just as well be a jQuery object. (As there is no hide function on DOM Elements by default)
anyone know how to get around [URL="http://fatslug.ca"]this[/URL]? The hover event or animation is shifting the background image which otherwise would repeat perfectly.
[QUOTE=Poo Monst3r;44218512]anyone know how to get around [URL="http://fatslug.ca"]this[/URL]? The hover event or animation is shifting the background image which otherwise would repeat perfectly.[/QUOTE]
Remove the margin attribute in the :hover selector
[QUOTE=Poo Monst3r;44218512]anyone know how to get around [URL="http://fatslug.ca"]this[/URL]? The hover event or animation is shifting the background image which otherwise would repeat perfectly.[/QUOTE]
I'd remove the background from the html tag and only apply it to your body tag, set your body's margin and padding to zero and it's height to 100%
[editline]12th March 2014[/editline]
[QUOTE=lkymky;44192994]So this is more of the separate your unique content from your code stuff that cbastard was talking about. Only this time javascript keeps requesting data in the form of json and depending on its own logic; content is filled via JS?
That sounds like alot of javascript.
I was thinking that I would definitely have javascript do something like request a new page when a link is clicked, but is there an equivalent to PHP's include in JS that I could use?[I] (Yes I know that is an idiotic statement but you get my drift) [/I] If say I wanted to send at least portions of HTML across the net
Also KmartSqrl you are very knowledgeable about PHP despite you not advocating its use. I appreciate the directions :v:[/QUOTE]
It can be a lot of JS, but there are libraries like [url=http://knockoutjs.com/]knockout.js[/url] that handle updating the DOM automatically and will save you writing a lot of code.
I don't always use something like knockout though, kind of depends how complex the front-end is going to end up.
You can definitely add arbitrary HTML to the DOM with javascript. There's quite a few different ways to do it, but that should be pretty easy to find if you google "Add html to page with javascript" or something like that.
No problem! I use PHP every day at my 9-5 and it was what I first learned when I started web dev so I'm pretty familiar with it. I just don't think it's the best tool for the job, so I don't recommend it :)
I want to get in to Ruby on Rails because i now asp.net and MVC but i feel that i could be nice to now something thats not windows related. So do anyone have any tips any good tutorials on the basics on Ruby on Rails.
[QUOTE=scroul;44224550]I want to get in to Ruby on Rails because i now asp.net and MVC but i feel that i could be nice to now something thats not windows related. So do anyone have any tips any good tutorials on the basics on Ruby on Rails.[/QUOTE]
I found [url=http://ruby.railstutorial.org/chapters/a-demo-app]this[/url] to be quite a good starting point when I was first learning Ruby on Rails.
[QUOTE=DaMastez;44224978]I found [url=http://ruby.railstutorial.org/chapters/a-demo-app]this[/url] to be quite a good starting point when I was first learning Ruby on Rails.[/QUOTE]
I second this, [url=http://ruby.railstutorial.org/ruby-on-rails-tutorial-book]Michael Hartl's free Rails Book[/url] is how I learned Rails, and it's great!
Have anyone got a good workflow with WordPress going? We're developing entire sites, not individual themes or plugins. At the moment, we keep the entire WP-installation (except wp-config.php) in git, but I have no idea what to do with the database.
[QUOTE=ArgvCompany;44225925]Have anyone got a good workflow with WordPress going? We're developing entire sites, not individual themes or plugins. At the moment, we keep the entire WP-installation (except wp-config.php) in git, but I have no idea what to do with the database.[/QUOTE]
Just back it up and move it around when you need to, you shouldn't really be doing anything that requires you to move your db around so often that you need something like git to manage it.
We use [url=http://wpengine.com/]WP Engine[/url] along with Git for our non wp-core files. Seems to work well enough.
I'm wanting to make a simple web control panel for my minecraft server, are there any good tutorials or guides on how to get started?
Sorry, you need to Log In to post a reply to this thread.