This may sound as a non related coding question but it's directly related :
The facts: I've developped a website (with symfony) which allows players to search for a team (like a job board). It makes one module only.
The problems I want the website to be even more accurate and make a custom form for each players depending on the game (for example, for those who play "league of legends" they'll have 3 more informations to fill up....)
The solutions?
One module per game (example: http://pastie.org/private/cl48jsrjreukyjmj7jrk8a).
I'm currently developping 1 module per game in order to take in consideration the specific criteria for specific games.
Advantages :
The player enters the informations in relation with his game and does not see/interact the other criteria
Disavantages:
90% of the code are the same between each modules. It takes more time.
Inheritance
I never played with that before so i don't know if it's possible in my case to stick with 1 module for the entire game collection AND taking in consideration the specific criterias for games. In that case it would mean to have 1 template per game and displaying the right template with the right accessors like
($this->getCV()->getPseudo(); / $this->getCV()->getGame()->getSpecificCriteria1();)
If I have read your question correctly, you want to show additional fields for each specific game.
Solution 1
Create a 2 form process. After your first form, you could redirect the user to a second form which depends on their answers. To do this, in your first form, use a redirect to send the user to a game-specific second form.
Solution 2
Pass the name of the game to the template and show a customised partial for the extra form fields. For this you will need a Url with a game parameter like this:
www.example.com/form/show/:game_identifier
Then in your action, read the parameter and pass it to your template.
In the template, show a partial dependant on the game that was passed through. So only show the extra fields if a specific game was chosen before hand.
There are further ways to accomplish this but these 2 sprung to mind first.
Related
I was wondering if anyone with some experience with PHP could help. I've been trying to figure out if there is a way within WordPress (GravityView) to make calculations based on certain entries within a form and then use conditional logic to display different images dependent on the result from this calculation.
In this case, I am trying to display different images relating to different measures of a client, i.e. their value to our company, their engagement with our company. Taking the example of Satisfaction I have added a field to one of our forms where if a request is completed unsuccessfully with them it will count that entry. However, I then need to sum all these unsuccessful entries so I can relate them to the different levels of satisfaction (the images). i.e if there are 10 unsuccessful entries for a given client they will be given a poor level of satisfaction and if there are 0 they would be given an excellent level of satisfaction. This is not possible to do within a view in gravity view as you cannot use a shortcode within a shortcode. I cannot sum all the entries using [gvmath] for a specific field and then use [gvlogic] to assign the different levels to different images. So I was wondering if there is a way to bypass this by issue by writing the code directly in PHP.
Also, another issue is within the form that is used for the requests there is a field where the member ID is inserted. Each of our individual clients is given a specific member ID and then a page is created for that client where their 'Levels' are displayed. So ideally the PHP code would be able to sum the entries for only that specific member ID and then using the result of that calculation assigns a particular image to it depending on the answer. Is this all getting too complicated and not able to be performed within WordPress? I've been trying to wrap my head around it all week so any help would be greatly appreciated.
I've attached a picture of the specific images that I would like to assign to the different levels.
Let me know if any further context to my issue is required.
Thanks :)
Levels
I am building a survey questionnaire in PHP using Laravel and there are five HTML pages (one for each section). Do I need to create separate controllers for each HTML page in order to process the data to the database?
Usually it is good to stick to the different logic-different controller.
As you provided very small amount of info, its not clear what you want to do, but based on the info I understand, you’ll just need one controller and one method for all the html pages.
I have a system where the user makes a post, this post will include a title, and the post content itself, the content will be anywhere between 20 - 3000 words and consist of plain text.
I also have a set of more then 700 categories, some are top level categories, the rest are subcategories.
When the user enters the content for their post, they need to be prompted with up to 5 relevant categories, selected automatically based on what the user has typed in.
What is the best way to do this, I am using PHP & MySQL, links to any libraries or code samples would be useful.
User perspective
You cannot do this on 1 step in the same page with only php/mysql. There are mainly 2 options for your question.
You also learn/use some client-side language and implement it to do a search without changing the page. I don't know much of it, so I cannot really recommend anything specific, but this thread should help you.
You use a middle page. That said, the user posts it's content, then after sending it you parse it and offer categories for the user to select in the new page. This has the problem that many users might close the window after pressing 'send' in a comment as they expect it to be sent straight, the good thing is that it only uses php/mysql.
Parsing the text
Once again I'm not sure if this is the most efficient way, but I'd try this and keep testing until achieving the result expected:
First, create a list of few keywords for each category. 4 or 5 should do the trick, but it depends greatly on the categories, text and many other factors.
Then, create an array of 10 elements. 5 would be the id of the category and 5 would be the 'score' for each category. You can set, for example, a score of 1 for each keyword found. Remember to asign some values initially or you'll have nothing to compare it to.
Then I'd search each category keywords in the text. If you get an score superior than any of those obtained previously, substitute the minimum one for the new category.
Echo the 5 categories remaining at the end of the script. They should be the 5 more suitable. But keep in mind that there are many more ways to approach this parsing problem.
I am building a Web application that allow people to subscribe to certain classes which are divided by semesters.
In one of my interface I have a list of all activities that act as a summary in the backend interface. I was looking to group them by semester and browse through a sequential navigation.
My problem is, where should I put my code since I want it to be easy to maintain and I want to respect the right MVC structure.
Here are my Ideas:
Get the param value in the controller, get the previous and next semester through an
action helper, send the data to the view and then display it
or
Get the param value in the controller, sent it to the view, let the view (through a
view helper) find the previous and next semester and then display it
I have a class that is able to find the semesters through calculation (so it's not in my models)
The first option. Your question is unclear to me, but your first option sounds the closest to what I would do.
I built a site using Drupal 6 recently that allows for users to submit information to the site owner in three different ways. They are:
Webform A: Quick Contact - this just collects name, email, phone and a message.
Webform B: Free PDF Book by Email Webform - this collects info similar to above, and then sends the user an email with a PDF attachment which is a book written by the site owner.
Node Create: Case Evaluation - this form is a Node Creation page using the Multi-Step module, CCK and a lot of conditional fields. Anonymous users can fill out this form and the node data is emailed to the site owner based on a Rule I created.
All three of these forms work perfectly in terms of doing what they are supposed to do for the site. The webform submissions are easily accessed from the webform node by the owner, and I set up a table view to manage the node submissions.
Even though the forms are gathering slightly different data, at the end of the day, the most important data is the personal contact information (each one collects name, email and/or phone), and each form submission (from any of the forms) is considered a lead by the owner and followed up on.
I would like to centralize these various form submissions (2 webforms + 1 node) into one Content Type (leads) so they could be managed from one page, rather than three, and so the owner doesn't have to reference/compare submissions from two other forms when working with data from one to prevent double-contacting potential clients if they filled out two forms on the site.
Is there an obvious solution for this scenario that could be implemented using some combination of existing modules and Rules. Or, any solution that would at least not stray too far from good Drupal practices?
What about converting the webforms to CCK too, and using a Views Bulk Operations scenario for aggregate/sort/filter capabilities?
I'm not convinced about your desire to consolidate to one content type. You should use one content type only when the forms are similar in structure and purpose. Webform A, Webform B and Case Evaluation seem to be satisfying totally different needs. They are not good candidates for consolidation.
Another alternative is to force people to register (i.e. become logged in users) before they access any webforms and CCK forms. Using the User profile (bundled with Drupal core) module you can collect standard data when people register that you now need to collect anyway for the three forms. It will consolidate your leads data in one place. The registration procedure can be made unobtrusive and simple.
I would also recommend that you use Webforms in general. They are user friendly and are excellent for making questionnaires and contact forms. Use CCK content types for more fundamental aspects of your sites like article content types and where you need views integration.
There is a very useful module called http://drupal.org/project/inline_registration . It allows you to register just before you create a node. I would guess it doesn't work with webform (unfortunately) but please check.
Another option which I feel might might be viable would be to have user fill out 2 forms. One quick webform which captures their basic details and the other webform/node create where they get to do their specific work like request a PDF etc. This way all your lead data gets captured into one webform for which you can get excel file exports.
Before signing off -- another point occurred to me...assume you have 3 webforms (Case Evaluation is turned into a webform). You just make sure that the initial data consists of standard fields like Name, Email address etc. You will get 3 excel sheets (one from each webform). It will be very easy to take the first 3 or 4 columns that you are interested from each sheet for leads data and then combine the data together in one "leads" excel sheet. This quick and dirty method will save you a lot of effort and to my mind will be a "good enough" solution.