xoops forums

preachur

Just can't stay away
Posted on: 2008/5/26 5:47
preachur
preachur (Show more)
Just can't stay away
Posts: 525
Since: 2006/2/4 4
#1

Recette on 2.0.18.1 - Ingredients and amounts required

On XOOPS 2.2 or 2.3 the recette (recipes) module works fine. on 2.0.18.1 all the ingredients are required. In other words, if you only enter 3 ingredients it wants you to fill up all the other fields before it will allow you to submit. Since there are 30 fields you can see why it doesn't work. I am thinking it is somewhere in this piece of code, but every time I try to fix it I mess up the whole thing.
for ( $ii=0;$ii<$nbingredient;$ii++ )
    {
        
$jj=$ii+1;
        ${
'ligne'.$ii} = new XoopsFormElementTray(_NW_INGREDIENT);
        if ( 
$ii+1>count($quantite) )
        {
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_QT'qt'.$jj1040''), true);
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_INGREDIENT'ing'.$jj2050''), true);        
        }
        else
        {
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_QT'qt'.$jj1040$quantite[$ii]), true);
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_INGREDIENT'ing'.$jj2050$ingredient[$ii]), true);
        }
        
$add_btn = new XoopsFormButton('''addIng'_NW_AJOUT_ING'submit');
        
$add_btn->setExtra('accesskey="a"');
        ${
'ligne'.$ii}->addElement($add_btn);
        
$sform->addElement(${'ligne'.$ii});
    }


Any help would be appreciated. Blessings!
Magick can never be restrained, but when freely given is thrice regained!

Peekay

XOOPS is my life!
Posted on: 2008/5/26 10:31
Peekay
Peekay (Show more)
XOOPS is my life!
Posts: 2335
Since: 2004/11/20
#2

Re: Recette on 2.0.18.1 - Ingredients and amounts required

I had a problem with the Recette module as described in this post. I was using XOOPS 2.0.13.2 at the time. I don't know if the disappearing field issue exists in 2.2. What version of Recette are you using?.
A thread is for life. Not just for Christmas.

preachur

Just can't stay away
Posted on: 2008/5/26 12:08
preachur
preachur (Show more)
Just can't stay away
Posts: 525
Since: 2006/2/4 4
#3

Re: Recette on 2.0.18.1 - Ingredients and amounts required

Version 2.2 of Recette... IF I can get it to work.

I am currently testing other modules to possibly modify something to work better. I HAD a recipe module I made myself in 2004 running, but it doesn't work quite right in 2.0.18. White screens on submit even though it does submit... and the ingredients and directions display on separate pages which annoys users. Plus, I don't think it is secure at all. So I am trying to get something better working.
Magick can never be restrained, but when freely given is thrice regained!

preachur

Just can't stay away
Posted on: 2008/5/26 23:13
preachur
preachur (Show more)
Just can't stay away
Posts: 525
Since: 2006/2/4 4
#4

Re: Recette on 2.0.18.1 - Ingredients and amounts required

Well, once again one of DJ's modules is bailing me out. I am using his Article module with a category for recipes. The module seriously has everything. It will easily handle all of my information sharing needs. Since it is a collaborative information portal, it will work perfectly.
Magick can never be restrained, but when freely given is thrice regained!

zyspec

Module Developer
Posted on: 2008/5/26 23:42
zyspec
zyspec (Show more)
Module Developer
Posts: 1077
Since: 2004/9/21
#5

Re: Recette on 2.0.18.1 - Ingredients and amounts required

Just for future reference, or in case someone else reads this and needs the answer...

The addElement function allows you to set whether a field is required or not... to change this in the above code just remove ', true' from the addElement() calls above. For example:

${'ligne'.$ii}->addElement(new XoopsFormText(_NW_QT'qt'.$jj1040''), true);


would become:
${'ligne'.$ii}->addElement(new XoopsFormText(_NW_QT'qt'.$jj1040''));

preachur

Just can't stay away
Posted on: 2008/5/26 23:51
preachur
preachur (Show more)
Just can't stay away
Posts: 525
Since: 2006/2/4 4
#6

Re: Recette on 2.0.18.1 - Ingredients and amounts required

Wow, thanks. I tried that, but I took the hash marks out as well and got a white screen. I will try that on my other site that has recipe listings.
Magick can never be restrained, but when freely given is thrice regained!

Yurdal

Friend of XOOPS
Posted on: 2008/5/28 22:00
Yurdal
Yurdal (Show more)
Friend of XOOPS
Posts: 367
Since: 2005/3/27
#7

Re: Recette on 2.0.18.1 - Ingredients and amounts required

Hmm i want to try the solution but which file must be edited ?

Lloyd

Just popping in
Posted on: 2008/5/28 23:34
Lloyd
Lloyd (Show more)
Just popping in
Posts: 43
Since: 2006/7/4 1
#8

Re: Recette on 2.0.18.1 - Ingredients and amounts required

Hmm i want to try the solution but which file must be edited ?


look in recette/include/storyform.inc.php around line 89

Yurdal

Friend of XOOPS
Posted on: 2008/5/29 8:20
Yurdal
Yurdal (Show more)
Friend of XOOPS
Posts: 367
Since: 2005/3/27
#9

Re: Recette on 2.0.18.1 - Ingredients and amounts required

Hmm i made a small change and it works now

Find:
// Ajout des ingr├ędients
$nbingredientF = new XoopsFormHidden('nbingredient'$nbingredient);
$sform->addElement($nbingredientF);
    
    for ( 
$ii=0;$ii<$nbingredient;$ii++ )
    {
        
$jj=$ii+1;
        ${
'ligne'.$ii} = new XoopsFormElementTray(_NW_INGREDIENT);
        if ( 
$ii+1>count($quantite) )
        {
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_QT'qt'.$jj1040''), true);
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_INGREDIENT'ing'.$jj2050''), true);        
        }
        else
        {
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_QT'qt'.$jj1040$quantite[$ii]), true);
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_INGREDIENT'ing'.$jj2050$ingredient[$ii]), true);
        }
        
$add_btn = new XoopsFormButton('''addIng'_NW_AJOUT_ING'submit');
        
$add_btn->setExtra('accesskey="a"');
        ${
'ligne'.$ii}->addElement($add_btn);
        
$sform->addElement(${'ligne'.$ii});
    }



Replace:

// Ajout des ingr├ędients
$nbingredientF = new XoopsFormHidden('nbingredient'$nbingredient);
$sform->addElement($nbingredientF);
    
    for ( 
$ii=0;$ii<$nbingredient;$ii++ )
    {
        
$jj=$ii+1;
        ${
'ligne'.$ii} = new XoopsFormElementTray(_NW_INGREDIENT);
        if ( 
$ii+1>count($quantite) )
        {
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_QT'qt'.$jj1040''), false);
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_INGREDIENT'ing'.$jj2050''), false);        
        }
        else
        {
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_QT'qt'.$jj1040$quantite[$ii]), false);
            ${
'ligne'.$ii}->addElement(new XoopsFormText(_NW_INGREDIENT'ing'.$jj2050$ingredient[$ii]), false);
        }
        
$add_btn = new XoopsFormButton('''addIng'_NW_AJOUT_ING'submit');
        
$add_btn->setExtra('accesskey="a"');
        ${
'ligne'.$ii}->addElement($add_btn);
        
$sform->addElement(${'ligne'.$ii});
    }

preachur

Just can't stay away
Posted on: 2008/7/23 19:31
preachur
preachur (Show more)
Just can't stay away
Posts: 525
Since: 2006/2/4 4
#10

Re: Recette on 2.0.18.1 - Ingredients and amounts required

I found an updated version of this module somewhere but I lost the link.... Updated in July and it works perfectly on 2.0.18. PM me if you need me to re-zip it and upload it. I also fixed a few poor english translations and added a title and submit button at the top.
Magick can never be restrained, but when freely given is thrice regained!