Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 09:42:18 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155535 Posts in 21713 Topics by 7737 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: module development: linking on view.php  (Read 813 times)
LuuQ

Offline Offline

Posts: 96



WWW
« on: May 29, 2010, 07:03:32 PM »

Hi

I am currently developing a new module for one of my costumers.

The structure of the module in the frontend should be like this:

First you see a table with different courses. When you click on a course you are linked to the next page where cou can fill in a form to sign in for the course.

Sth. like this:

1...table with the courses (view.php)
.........link to form
.........link to form
.........link to form
2...form
3...form_submit

So my question is now: When I have the first page with the table in the view.php of the module, where do I have to put the second page with the form? How do I have to call this file?
And how do I have to set the links in the view.php that the form-file is displayed when I click on a link?

The same question can be asked for file 3 (form_submit).

I tried to create a new code page for the form, but it wasn't displayed correctly, even though I included the frontend.css of the module for the styles.

I hope you know what I mean, it's a bit weird, I know.
I'm sorry that I cannot give you a link. I'm developing it locally with XAMPP.


Best regards,

LuuQ
Logged
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2296



WWW
« Reply #1 on: May 29, 2010, 10:10:04 PM »

You could build your three pages in the same view.php.

if (step==0) {
//build table
} elseif (step == 1) {
//build form
} else {
//proccess form, display result
}

your links, with parameters would point to the current page only
Logged

Professional WebsiteBaker Solutions
quinto

Offline Offline

Posts: 67


WWW
« Reply #2 on: May 29, 2010, 10:19:02 PM »

Hi

I am currently developing a new module for one of my costumers.



Will your module be open-source ?
Logged
LuuQ

Offline Offline

Posts: 96



WWW
« Reply #3 on: May 30, 2010, 01:26:21 AM »

@Ruud:

That works perfectly. Thank you very much!
Do most of the modules work like this?

@quinto:

This module is just for one of my costumers and it's really very specialised just for one purpose. At the current status I don't think that anybody could make use of it. But maybe, if I find time to work on it, I could try to build a open-source module of it.

Maybe you want to know what it can do:
It's a course signup module (I'm building it for a cookery school). You can define course categories and then courses for the different categories. These are displayed in the frontend, where people can sign up for them.
It's my first PHP/MySQL project as well as my first private module for websitebaker. I couldn't completely include it in the backend yet, I just included a link to the backend that I built by myself. I don't completely have the clue how the modules work in websitebaker. But with pursuing the module primer tutorial and studying module source codes I will maybe get it.


Best regards,

LuuQ
Logged
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2296



WWW
« Reply #4 on: May 30, 2010, 09:45:42 PM »

@Ruud:

That works perfectly. Thank you very much!
Do most of the modules work like this?

For modules/pages that are using different states or "user steps" dynamically it is just the logical way to work.
Logged

Professional WebsiteBaker Solutions
sciclist

Offline Offline

Posts: 6


« Reply #5 on: June 23, 2010, 10:40:01 PM »

You could build your three pages in the same view.php.

...

I'm trying to do something vaguely similar and I don't understand this solution.

How can the form contents be SUBMITed to view.php itself? view.php does not generate a full HTML page.

If the form is submitted via a "normal" WB page_id to a hidden page which also contains my module how are the form contents passed to this second instantiation of view.php?

Thanks for your time.

Logged
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2296



WWW
« Reply #6 on: June 23, 2010, 10:53:56 PM »

view.php does not generate a full HTML page.

Yes it is.. the module view.php is generating his own part on the output. Other secions might add stuff.. WB will add the template..
Submitting data to the current page can be picked up by any module on the current page. Most likely it will be your view.php that is processing any formdata that it generated the first time.

I would suggest that you download a bunch of other modules and have a look how these modules handle the processing of form data.
Logged

Professional WebsiteBaker Solutions
LuuQ

Offline Offline

Posts: 96



WWW
« Reply #7 on: June 23, 2010, 11:15:12 PM »

Basically, it works like this. Maybe this excerpt of my code can help you:

Code:
<?php

        
// Check the step

        
if (isset($_GET['s']) == true) {
$step $_GET['s'];
}
else {
$step 0// set step to 0 so the first page will be shown
}


if ($step == 0) {
}

elseif ($step == 1) {
}

elseif ($step == 2) {
}

?>


So, it's just working with ifs and elseifs.

When you add a form to this, it can look like this:
You always add a variable to the links with the number of the step you want to do.

Look at the form action in the second step.

Code:
<?php

        
// Check the step

        
if (isset($_GET['s']) == true) {
$step $_GET['s'];
}
else {
$step 0// set step to 0 so the first page will be shown
}

//// First Step

if ($step == 0) {

            
// Write something... put a link to the form with a certain id and the number of the step (s=1)
            // The view.php opens itself with s=1 (see second step)
           
$link "?id="25"&s=1";

// End First Step


//// Second Step

elseif ($step == 1) {

// GET step number
$id $_GET['id'];
        
                        
// When the form is sent, it's sent to the view.php with step = 2
echo "
<form action='?s=2' method='post'> 
<table>
<tr>
<td>Anzahl Personen</td>
<td>
<select name='personenzahl' size='1'>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
</select>                
</td>
</tr>
<tr>
<td></td>
<td><input type='submit' value='Send' /></td>
</tr>
<tr>
<td></td>
<td><a href='?s=0'>Abort</a></td> 
</tr>
</table> 
</form>
</div>"
;
}


// End Second Step

//// Third Step - Send E-Mail

elseif ($step == 2) {
// get data per POST from step = 1

$personenzahl $_POST['personenzahl'];

// Send E-Mail
if (mail($empfaenger$betreff$text$from)) {
  echo "Successful<br /><br />";
  echo "<a href='?s=0'>Back</a>";
}
}
}

?>

Hope this helps!


Best regards,

LuuQ


Logged
sciclist

Offline Offline

Posts: 6


« Reply #8 on: June 27, 2010, 01:51:35 PM »

Thanks Ruud and LuuQ for the guidance. It is perfectly clear to me now.

Sciclist
Logged
LuuQ

Offline Offline

Posts: 96



WWW
« Reply #9 on: September 11, 2010, 05:17:28 PM »

Still working on that module. Now I was able to implement it in the backend.

But sth. doesn't work: the jQuery datePicker. Is it possible that this is blocked by the CMS itself? It's clear to me how it works with the backend.js and so on, but I cannot get it to work.

Thanks,

LuuQ
Logged
LuuQ

Offline Offline

Posts: 96



WWW
« Reply #10 on: October 19, 2010, 08:02:54 PM »

Still working on that module. Now I was able to implement it in the backend.

But sth. doesn't work: the jQuery datePicker. Is it possible that this is blocked by the CMS itself? It's clear to me how it works with the backend.js and so on, but I cannot get it to work.

Finally works. Somehow the jquery-ui-min.js wasn't included correctly. That's why the datepicker never appeared.
I found that there are jquery includes in the footer of the argos theme. Why that? Why in the footer?
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!