1
sottwell
Re: Using form class
  • 2004/7/11 12:47

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


Nope...still just one text input element.

The Smarty loop works fine like so:

<{section name="ingredients" start=0 loop=9}>
   <
tr>
        <
td><input type="text" name="ingred[]" size="30"></td>
        <
td><input type="text" name="ingred[]" size="30"></td>
    </
tr>
<{/
section}>


But gives me a nasty error like so:
<{section name="ingredients" start=0 loop=9}>
   <
tr>
        <
td><{$addrecipeform.elements.ingred[].body}></td>
        <
td><{$addrecipeform.elements.ingred[].body}></td>
    </
tr>
<{/
section}>


Fatal error: Smarty: [in db:addrecipe_form.html line 20]: syntax error: unrecognized tag: $addrecipeform.elements.ingred[].body (Smarty_Compiler.class.php, line 382) in /Library/WebServer/Documents/xoops/class/smarty/Smarty_Compiler.class.php on line 1824

Displays fine if I get rid of the [] in the element name, except then the database insert fails (of course!). I really don't want to get involved in complex array loading from POST variables.

Tried escaping the brackets, and it skipped the loop altogether. Oh, well...I'll just go with the first loop, while this is a lot of fun learning, I would like to move ahead with this module.

Thanks!





2
sottwell
Re: Using form class
  • 2004/7/11 11:57

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


.
.
.
$addrecipe_form = new XoopsSimpleForm(_JYR_ADDRECIPE"addrecipeform""addrecipe.php");

// add elements to form

$addrecipe_form->addElement($category_select);
$addrecipe_form->addElement($recipename_text);

// loop here

for($i=0;$i<16;$i++) {
$addrecipe_form->addElement($ingred_text);
}

$addrecipe_form->addElement($directions_textarea);
.
.
.


and the template HTML:

<table class="outer" cellspacing="1">
        <{foreach 
item=element from=$addrecipeform.elements}>
            <
tr>
                 <
td class="head"><{$element.caption}></td>
                 <
td><{$element.body}></td>
             </
tr>
        <{/foreach}>
</
table>


Still only adds one $ingred_text element to the form.

It looks like you can only add an element once. That's fine with me, so how would I create a group of elements and add the group?

I don't see how the Smarty section would work, since I don't have an array of text elements to work with!



3
sottwell
Re: Using form class
  • 2004/7/11 10:08

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


Sorry...it just doesn't do anything with the element if I try to use a loop to create multiple identical elements. No error messages in any of the debug modes, either.

Anyway, I would like to know the proper procedure for creating a group of identical text input fields. I'm sure it's a matter of ignorance here.

I did it by hand in the template with HTML, and everything works fine, but that's cheating!

<tr>
<
th colspan="2"><{$addrecipeform.elements.ingred.caption}></th>
</
tr>   
<
tr>
<
td><input type="text" name="ingred[]" size="30"></td>
<
td><input type="text" name="ingred[]" size="30"></td>
</
tr>
<
tr>
<
td><input type="text" name="ingred[]" size="30"></td>
<
td><input type="text" name="ingred[]" size="30"></td>
</
tr>
<
tr>
<
td><input type="text" name="ingred[]" size="30"></td>
<
td><input type="text" name="ingred[]" size="30"></td>
</
tr>
<
tr>
<
td><input type="text" name="ingred[]" size="30"></td>
<
td><input type="text" name="ingred[]" size="30"></td>
</
tr>

etc etc...


What I want to do is to create the array of elements somehow:

$ingred_text = new XoopsFormText(_JYR_INGRED"ingred[]"30100"");
.
.
.
$addrecipe_form->addElement($ingred_text);
.
.
.

with some kind of loop somewhere.



4
sottwell
Re: Friendfinder 3.1 problem
  • 2004/7/11 9:47

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


I even tried having some single quote characters in the name...works fine. For me, anyway. It should; any database insertion should only be done after "sanitizing" the POST input, which includes adding slashes to escape any troublesome characters for the sql.



5
sottwell
Re: Friendfinder 3.1 problem
  • 2004/7/11 9:39

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


Installed it, ran it "out-of-the-box", (except for checking file ownership and permissions), and it worked fine up until I wanted to view a user's profile, and commenting out the block of code mentioned above fixed that. No help, I know, but at least you can know that it does work ... sometimes

That block of code doesn't work because the function moduleExists doesn't exist as part of the XoopsModule object in the version of XOOPS you're using.

It's not important, it's just a nice bit of cross-module scripting; if you have the directfriends module installed this will (a little further down in the view.php script) create a link to the addfriend page in the directfriends module, automatically inserting the user id in the form on that page. The module will live just fine without it.

You don't have to delete it, just surround the whole block with /* */ multiline comment tags. Maybe someday you'll want to fix it and use it.

There are a LOT of notices involving the various variables and constant definitions, I'll see if I can figure out what's causing them and clear them out.




6
sottwell
Re: HTML Code messed up in PHP source code (a beginner question)
  • 2004/7/11 7:36

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


http://wiki.xoops.org/wakka.php?wakka=HomePage

Some explanations and tutorials here. Also check links on left column of this page



7
sottwell
Re: Problem creating a bulk insert script.
  • 2004/7/11 7:06

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


Did you check your database to see exactly what got inserted into the fields in question? I had a similar problem with avatars, viewing source showed truncated image filenames, and when I looked into the database (using phpmyadmin) I saw that the filenames were getting truncated on insertion because the field was limited to fewer characters than my filenames were using.

It would be easier for you if you cleaned up your queries; for example used a single-quote (') instead of double quote (") for your insert values so you wouldn't need to be escaping all those quotes. MySQL likes single-quotes just fine. You only need to escape them if they're used as part of an insert value (e.g. O'Reilley in a name field). Then, create simple variables to use in the query before writing the string; for example:

$url $DownloadBaseUrl $file;
$size filesize($file);
$thislogourl $ShotBaseUrl $logourl;


then you could have:

"insert into xoops_mydownloads_downloads 
 (cid,title,url,size,logourl,submitter,status,date,homepage,version,platform) 
 values (2,'
$title','$url','$size','$thislogourl',...etc";


Also usually in XOOPS it's a good idea to say:

"insert into " .XOOPS_DB_PREFIX"_mydownloads_downloads...


just in case somebody isn't using the default XOOPS table prefix.

Just a few thoughts I had that might help, since I'm also new at Xoops, although I've been working with PHP and MySQL for a few years.



8
sottwell
Using form class
  • 2004/7/11 5:06

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


I need to have a group of identical input text fields. I can easily do this by hand in the template, but how would I get the XOOPS form generator class to do it?

<tr>
        <
td><input type="text" name="ingred[]" size="30"></td>
        <
td><input type="text" name="ingred[]" size="30"></td>
    </
tr>    
    <
tr>
        <
td><input type="text" name="ingred[]" size="30"></td>
        <
td><input type="text" name="ingred[]" size="30"></td>
    </
tr>
    <
tr>
        <
td><input type="text" name="ingred[]" size="30"></td>
        <
td><input type="text" name="ingred[]" size="30"></td>
    </
tr>


It seems like the field's name including brackets makes either XOOPS or Smarty unhappy. I can use it if I only generate one field, but it chokes if I try to create several of them.

$ingred_text = new XoopsFormText(_JYR_INGRED"ingred[]"30100"");

...

$addrecipe_form = new XoopsSimpleForm(_JYR_ADDRECIPE"addrecipeform""addrecipe.php");

// need to loop this somehow/somewhere ????
$addrecipe_form->addElement($ingred_text);


Am I looking in the wrong place? Should I create a group of them somehow in the template? I would prefer to handle them at the generation level than at the display level.



9
sottwell
Re: Most extensive module you can think of (I'm going to attempt at a tutorial)
  • 2004/7/11 4:26

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


Missed the "main.php" language file. It's in there now. Sorry about that! And thanks!



10
sottwell
Re: News Module - Categories and Subcategories
  • 2004/7/9 6:52

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


No, not necessarily. Consider a graphical representation of a file system, such as the typical folder icon. The individual files are only shown when you open the folder the files actually reside in. Opening a parent folder shows any child folders and any files residing in the parent folder, not the files residing in the child folder.

Imagine if at the root directory of your OS of choice you saw a listing of all the files on the disk at once! It's certainly possible to do this if it's what you need, but it's hardly what you would want to have when you're just looking for one of your mp3 files to play.

Likewise, if I want to read an article about dogs, I'm really not interesting in having to pick through a long list of articles about other unrelated topics. A plain category list is much better for me. That's why you have categories and subcategories to begin with.




TopTop
(1) 2 3 »



Login

Who's Online

232 user(s) are online (149 user(s) are browsing Support Forums)


Members: 0


Guests: 232


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits