Symfony2 - How to populated a select field with a very large amount of data (nearly 40.000) - forms

I use Symfony 2. I have so far 2 bundles. The first bundle is a called UserBundle and is build using FosUserBundle. The second bundle is called GeoBundle and contains one entity called France which's table contain almost 40.000 records. Each record refers to a city with postal code, regional code.... Basically I use this entity in my user registration form so that the user can select an appropriate city from the list. By the way I use an Entity Field Type to do that.
My problem is that everything is working fine with just a few records in the table but with the almost 40.000 records the page where my form is, is not even opening. I already extended my memory in php.ini to 256M and more but the page is still not opening.
So my question is simple. What would be the best solution to populate a select field with that many records? I am of course open to other solutions. Thank you in advance. Cheers. Marc

You're probably best using an autocomplete field. You can find plenty of solutions on Google. Or try a bundle like https://github.com/shtumi/ShtumiUsefulBundle

Simply don't load the full list, that would be bad for your server, your bandwidth and for the memory required by the client (if it's a mobile browser, forget it!)
I suggest to use jQuery UI Autocomplete, this is a jQuery plug-in that can load the elements required via Ajax from your server, so you don't have to load the hole thing. It's also well tested and easy to implement.
http://jqueryui.com/autocomplete/#remote-jsonp

Try using this Symfony2 bundle.
https://github.com/genemu/GenemuFormBundle/blob/master/Resources/doc/jquery/autocomplete/text.md
This is very helful and in Symfony2. It will save your time and have a look at its other extensions

Related

Is there a way to permanently add a box displaying points of students in the navbar

So I am working on a project that awards points to students for submitting assignments or participating in forums, these points are then exposed as an Http resource using Flask.
The points are calculated by looking at the events triggered for each student.
One of the requirements right now is to add a box next to the student's name that shows the total amount of points they have. I have two ways of accessing the points, either by an http request from moodle or by storing and retrieving the points from moodle's database.
My question is what is the best approach of creating this "box", I have tried using moodle blocks and hacking the code but nothing seems to be working. Is creating a plugin for this the only solution or is there a simpler way to do it (if it is even possible)?
To answer your question properly you should have provided at least the theme and the Moodle version you work with. Should this box be displayed everywhere? Is the score calculated for every course individually?
Two proposals that came into my mind:
You could create a custom plugin of type block. There you can display the score of the user of the session and the top ten for example (If the score is calculated for each course individually). A disadvantage is that every teacher of a course could remove that block easily, if he or she wants to.
If the score counts system-wide you could put that box at the start page of your Moodle website, where only people with higher rights will be able to remove it.
If you use boost you could display the score in the navbar right next to the users name. For that you will have to create a new child theme of boost and overwrite navbar.mustache of theme_boost which get's it's information from columns2.php because it's included into columns2.mustache. In this PHP file you can include your logic and display it with the HTML which you put into navbar.mustache.
Of course these are not really simple ways to do that. But at the moment I doubt that an easy solution exists for this problem.

Some questions before choosing/start learning Yii framework

I've been developing simple PHP/MySQL web sites for some years.
Never used a PHP Framework before and I understand I'll need to know OOP, no problem.
I'm about to start a SaaS project of my own.
A)
So far, I've seen Yii generates the CRUD and pages according to the DB.
Is it easy to modify the generated code?, like, adding a new DB field and its form field without not generating again all the stuff every time I change something in the DB and losing other customizations?
I mean, I'm 100% sure the generated DB code and pages are not going to be enough and I'll be constantly adding and correcting fields, and adding more tables etc.
B )
My project will include a Shopping Cart and Calendar(for events, tasks, etc.).
Does Yii has these options or at least an easy way to implement it like the Authentication options or Database listing, etc.?
C) Does documentation has this explained as a tutorial/book or is more like a reference(minimum explanation that only advanced user understand how to integrate it)?
thank you very much
Yiiframework has excelent documentation (you can start from here). Also there is an extensions area in the downloads section where you can find all available yii extensions.
All your questions can be answered if you follow their easy tutorial.
A) Yes, it's easy. You will just add code for new fields not changing it all.
B and C are answered by Stratosgear very well.
Is it easy to modify the generated code?
Yes it is. If you later decide to add more fields to the table, you can do that from your Phpmyadmin using sql commands.
You also need to edit the generated class file adding those new fields to correspond with that on your table.

How to pre-populate custom field in signup form for secure zone in Adobe Business Catalyst?

I have created a signup form for secure zone in Business Catalyst. I want to give user access to that form in order to update the fields. I have created the page and its working only problem is there is no way to pre-populate custom fields in the form. I talked to their support and research a lot but all in vain. This is very basic thing BC missing. Is there a hack for it or some alternatives?
Just adding for anyone finding this that you can also populate fields that have been created and extended in the crm if they're stored against the customer record.
{module_customerfield,crmextformID,FieldID}
eg
{module_customerfield,7470,82256}
More info in the forums.
Good News Now Business Catalyst supports this feature for more information read:
Allowing Customers to view and update CRM details
I have had this same issue and hopefully there will be someway they can fix this in the future. What I did for the time being is I used other tags that I was not using. IE module_workcity was not and won't be used by me so I then put that in a field that I needed the custom tag for. Here is a screen shot of what I am referring to. - http://screencast.com/t/b3pvuOcTi one thing to note here the screen name is different than username for this site.
Note: When the user signs up I have the person filling out a field for the "workcity" and just change the labeling.
Not sure if this is an option for you, and it can take some work but might help.
Hope this helps. - Another note BC related question you will get quicker answers on the forums there - http://businesscatalyst.com/support/forums

How do websites change content daily?

I just started learning HTML and CSS, with no knowledge on other languages such as javascript, Php, and so forth. Websites like Refdesk.com boast fresh content everyday, there has to be someway they are able to have new content everyday other then changing it by hand. Some Google searches came up with nothing but RSS feeds.
How is this done?
Thanks for the helpful answers, it answers half of my question, but does this also mean that the owner would have to manually add the webpage each day for new content, or say add in the content for a few days and have them displayed day after day automatically?
Most dynamic websites derive their page content from a database. Change the content in the database, and the content on the pages changes to follow suit.
Likely they have some form of content management system which allows non-technical users to update the site. In some systems, the content manager itself can get quite advanced. Here's a description of the latest version of the one used at the BBC, CPS, which drives the many BBC websites and more.
They most probably use a database where they store the content and the newest entries are retrieved from this database and displayed. This requires a server side language like PHP, Java, Python.
The HTML is generated dynamically.
The answers about databases combined with a server-side language like PHP are pretty good and very direct, but depending on how new you are to web development they might not be conceptual enough.
The first thing you need to understand is that a database is a collection of tables - each like any you might be familiar with in excel.
For example, one table in your database might be named "daily_links" and it might have two columns, one named "Date", and one named "Link". So every time you want to publish a new link, you just make a new row.
So now you are half way there.
Now what the server-side scripting language is able to do is to go to the database, look at your table "daily_links" and bring back each all the information that it found there.
From there it can do anything with that information like make a new anchor tag in html for each row it found, and give it an href of the data found in the column "Link".
That is rough idea in (very) general terms.
I hope that is easy to understand.

What's the max JSON data size that can be loaded by Dojo ComboBox/Filtering Select Component?

I'm developing a form using the Zend Framework and utilising dojo. One part of the form is gathering a users contact details and address. The issue I am hitting is using the FilteringSelect or ComboBox dojo component to select the city/town. I have in my database a list of 40K+ town/city names.
I've tried to use the Dojo component to grab this list but fear that 40K town names is just too big. I don't want to manually use a standard html component as I am sure that all that extra text in the page would make my form a nightmare to load.
So I suppose my question is in 2 parts:
What's the maximum JSON data size I can realistically expect to use, as I expect that what I am using is too big.
What would be the best way of allowing users to select one of these town names in the form?
Thanks in advance.
Youch, that's a big list of data points. I'd say it's really dependent on the user's browsers and settings. And tolerance for waiting.
If you are able, I'd say to put the data behind a web service and use the the dojox.data.QueryReadStore. That page even has an example of using a service to query states using a ComboBox.
<script>
dojo.require("dojox.data.QueryReadStore");
dojo.require("dijit.form.ComboBox");
</script>
....
<b>Combo lookup of states through QueryReadStore</b><br>
<div dojoType="dojox.data.QueryReadStore" url="/moin_static163/js/dojo/trunk/release/dojo/dojox/data/tests/stores/QueryReadStore.php" jsId="comboStore"></div>
<div dojoType="dijit.form.ComboBox" store="comboStore" searchAttr="name" pageSize="100"></div>
QueryReadStore.php is available in svn so you could even look at what they did server side.