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 5 years ago.
Improve this question
I'm currently working on my school project and I started wondering if it's a good approach to pass some variable through href so it can been seen in the URL.
Is it good or a bad way and why?
Or are there any better ways?
If it's not information that should be private I don't see why you couldn't do it. Especially if you need to reference something on a new page, it would make things easier.
It is good practice to use GET parameters for navigation purposes.
For user data input you can better use forms with POST.
Related
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
Sometimes I see things like this:
<?php echo $this->getLayout()->createBlock("menupro/menu")->setGroup_id(5)->setTemplate("menupro/menupro.phtml")->toHtml(); ?>
I was wondering whether this is a good practise?
This is a rather subjective question, I personally am all for it. You can make your code a lot more readable. Check out this link:
Effects of method chaining
The major drawback is that you must return the object. You may not return any other value as you’re only allowed to return $this.
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 8 years ago.
Improve this question
Which one of these styles are prefered when retrieving data to display in a view?
Straight forward laravel with no custom methods in the model:
$guest->bookings->first()->id;
$guest->bookings->first()->bed;
$guest->bookings->first()->date;
or a method to get the latest booking model:
$guest->getLatestBooking()->id;
$guest->getLatestBooking()->bed;
$guest->getLatestBooking()->date;
or seperate methods for each value like this:
$guest->getLatestBookingId();
$guest->getLatestBookingBed();
$guest->getLatestBookingDate();
It depends if you need to attach other queries (like 'where', or 'select'). This doesn't mean that you always have to use the second option, third is excellent too. For the first one, try to avoid it.
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 8 years ago.
Improve this question
For example, I have a form. Depending on the answers of the form, I want to take them to a different page on my site after submission. Here this is how I would think to do this assuming the action attribute of the form is submitted.php:
In submitted.php, do what the script needs to do based on the answers of the form, and then direct them by setting the header in php.
I'm asking this question because I hear a lot of people say you shouldn't bounce people around using headers.
So what way is best, if not my solution, and what is the argument against using header('location:');?
Thanks
Sending a Location header is exactly what you should do. There is nothing wrong in doing the following:
header('Location: http://www.site.com/?answer=' . rawurlencode($_POST['answer']));
Except for input validation, but that is subject of another discussion.
I don't know of any arguments against using header()-redirects in PHP. Just make sure you don't exaggerate and redirect from a redirect to another redirect…
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 8 years ago.
Improve this question
Similar to Facebook, I want to do a sharing feature where a user can choose to keep something private or share with 1 or more people. I know how to do a drop down but that limits my ability to be able to do it only for one person. How do i do it so i can allow people to select more than 1 person in a way that its user friendly and not confusing.
I was thinking of using AJAX or if HTML5 had something but i am new to that area so i don't know.
What is the best way to do it?
You could use a <select multiple>, but that's not very user-friendly. I'd use something like this: http://jqueryui.com/demos/autocomplete/#multiple.
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 9 years ago.
Improve this question
Is defining width for all objects (inputs, divs etc.) with percentage is a good way for making design fit for smartphones? Or what other way to do it?
I would recommend you use a less flexible layout, and instead use media queries. You can specify a set of rules in case the browser window is less than Npx width.
You should check out Twitter Bootstrap to help with this.