PHP - Load variable page content - php

Apologies again, as I'm new to PHP so not fully sure how this works, but thought I'd ask.
I have a page called contract.php, which I'm hoping to use as a template so that when someone selects the contract they wish to view it goes to the contract.php and loads the content for that particular contract.
Hopefully I shouldn't need to create a page for every single contract, I was hoping that I could use the contract ID, so that when the navigate to the page it would show something like contracts.php?contractid=555 and then loads the contracts details for contractid 555, so this does this for each new contract that's listed.
The issue I'm having is, I'm not sure how best to go about it, or how to use this ?contractid='xxx' etc.
Any help would be appreciated.
Many thanks

$_GET manual.
after reading the contract id from the get variable, you can search your DB for that contract and echo the specific data of this contract.
Also consider using $_POST so that you can't easily see any contract by changing the url by yourself

You can fetch respective data from your database for each contract using the contract ID. Inside the contracts.php, check whether contractid variable is set and not empty, using isset($_GET['contractid']) && !empty($_GET['contractid']). If it is true, then fetch respective data from the DB and display it to the user, in the template that you must have created.
Hope this helps. If you need more help then paste your code here.

Related

Accessing x-modal data and storing in database

I am having some trouble accessing x-model data in my laravel app and storing it into my database. Wondering if anyone can help.
So the issue seems to be coming from the fact that I have the category select as a separate blade that I call multiple times.
So ultimately, this code is called three times on my main page. I can then choose three separate categories - but when I try to call those selections and store them in database I run into an error.
Wondering if anyone has any ideas how to access the three separate categories being selected and add them to database. Some links or documentation to check out would be mighty helpful!
Using alpinejs, php, and laravel.
EDIT
In this particular case I am passing the information into the blade through the controller.
EDIT 2:this shows $selection_id
x-model takes the name of a variable inside x-data, not the value.
$selection_id here is a value.
You should do something like:
x-data="{ selection_id: {{$selection_id}} }"
on the component element
then inside x-model:
x-model="selection_id"
Note: Your code is missing, please add the part with the `x-data showing.

using "child" pages or iframes or other within php

trying to figure out how to best display a bunch of information on a "mother" page.
When I enter the first page, which is populated based on a GET method for a specific "id". on this page, I want to have an area where the user can click on either a link or button or other which will display a subsection in a single location. These pages will need to display the appropriate information based on data located on the page.
Would the best way just to be to create an iframe?
I'm unclear, as to how I best get this information to change appropriately (i'm still quite new to this process).
would I continue to use the GET method still on the "child" page; Do I also need to use a POST method somewhere?
any guidance would be great.
The better approach is to use ajax to populate that div.

Joomla Virtuemart 2 plgVmOnSelectPayment()

How can I add a form or HTML output to plgVmOnSelectPayment()?
I see no documentation about that.
I don't know this event Virtuemart payment select works.
I want add after selection a form with input fields.
Can anyone help ?
The plgVmOnSelectPayment() from what I've reversed engineered doesn't give any output to the HTML, but you can modify the cart content with that event.
I was myself in need of adding a form after a particular payment method was selected (to guarantee some additional data being supplied). Depending on where you want it you can either edit the View for the cart and add an if-statement where you see if the particular payment method is chosen. And then later access this information from plgVmConfirmedOrder() (you can access it through the $_POST global.
(This is an untested theory)
If you want to add the information to the field you can access the display form and add information there through the plgVmDisplayListFEPayment() event. Look in the vmPSPlugin class to see how they manage it there. What I did was simply copy that to get an image into that form, but you should be able to add other things there as well. And then you might be able to access the information there through plgVmOnSelectPayment() and using the $_POST global.
As a fair warning. All this I've gotten through reverse engineering VirtueMart. So it's neither pictue perfect nor might it be best practice. But the VirtueMart documentation leave not many other options :(. So if someone have a better way, I'm very interested in knowing that as well!

How do I display varying pieces of data through a fixed template without making multiple slightly altered 'include' files?

I have a database of different stores.
When a user clicks on a store name, I want an Ajax function to run displaying information about the store in a different div.
Information categories for all stores wll be the same: products carried, location, general information, etc.
I could easily make it so that each different store uses a different file name as an argument to the ajax function, and all files would have the same layout/format but with different data.
However i feel like this is bad form. How can i make it so that i have one fixed template and all that changes is the information specifics imputed into the template?
Please note that the store information display pages will also need to be able to have clickable links of their own (i.e. click on location and a google map pops up).
Is it something to do with XML? I dont know much about it.
Instead of returning a template, return the data.
So it says getstore.php?id=2 which returns a json string
{"name":"my store", "info" :"blah"}
Then you use java script to insert a new div, populated with that data.

How does the signup process work in socialengine? How/What and when is code called

I'm working on modifying a copy of social engine so that the sign up process includes an initial survey. I've already got a view, drawn my form however I'm not sure where the logic is processed. I know there are methods inside the corresponding controller but I'd like to save the data once the entire of the sign up process has finished.
Can anyone give me an overview of how the sign up process works in terms of MVC structure and communication?
Just for future reference I've added a blog post that I've created about this subject. It essentially boils down to creating new plugins/views/forms and editing the database in the engine4_user_signup table.
See the full post below for a more in depth discussion
http://garbtech.co.uk/socialengine-modify-sign-up-process/
Each plugin saves the data to the session on submit. Once the user finishes going thru the steps, the session should now contain all valid data. A transaction is then created, and all data is saved to the database. Thats basically how it works.
Of course the plugins can get a bit complicated if you are creating one. I created one myself and it took me a few days. Even then I didnt 100% understand the process, but I believe Ive got it down pretty good now.
You might want to add an extra step in the signup process. For this you need to create a new signup plugin. Take a look at this table- engine4_user_signup, you can see the plugin classes listed here. The classes are located in this folder- \application\modules\User\Plugin\Signup, you have to create a new one here. If you go through these classes you'll probably have an idea how to do what you are looking to do.

Categories