Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Getting Undefined Variable error HELP!! 
 
rattler72
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2009-08-13
West Vancouver, BC Canada
 

This should be simple for someone and I need to solve this fast.

I am trying to set a flag $firstOptionLine the first time /template/catalog/product/view/options/type/text.phtml is called.

But get this error:

Notice: Undefined variable: firstOptionLine in /usr/home/stationery/Websites/stationery.retrix.net/app/design/frontend/default/stationery/template/catalog/product/view/options/type/text.phtml on line 29

I declared the variable in /template/catalog/product/view/options.phtml near the bottom of the file here:

<?php $firstOptionLine true?>
    <?php 
foreach($_options as $_option): ?>
    <?php 
echo $this->getOptionHtml($_option?>
<?php 
endforeach; ?>

Any idea how to declare these global variables in general in Magento? I’m stumped.

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
rattler72
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2009-08-13
West Vancouver, BC Canada
 

Well I’m trying to set a flag the first time that file is called so I can add some html content / heading above the block.

 
Magento Community Magento Community
Magento Community
Magento Community
 
rattler72
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2009-08-13
West Vancouver, BC Canada
 

Basically I have a couple sets of options…

A set of radio buttons and a set of text fields. I want to put a heading between the radio buttons and the text fields.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

@rattler72 Is there a reason you do not use js to do what you intend?  Otherwise, I am also interested to know how to pass a variable from one scope to another. I did it the last time using DB, which required settings in config.xml and sql setup and I had to host the variables in a custom Model. You can also investigate Mage::registry, which is not designed for this purpose.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

@dd_gi Thanks for the tips.

Session variables is interesting. See http://www.magentocommerce.com/boards/viewthread/11729/#t58439

 
Magento Community Magento Community
Magento Community
Magento Community
 
rattler72
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2009-08-13
West Vancouver, BC Canada
 
dd_gi - 03 September 2009 05:31 PM

Try to mock up a screen shot of how you want it to look so I can see what you want exactly.

Here is what I’m trying to layout (see attached):


There are a set of radio buttons above.
Then a heading below that: “PERSONALIZED TEXT up to 6 lines”.
Then I have 6 lines of text fields below that.

These are all set up as options in my product.

Image Attachments
options_layout.JPG
 
Magento Community Magento Community
Magento Community
Magento Community
 
rattler72
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2009-08-13
West Vancouver, BC Canada
 

Setting session variables might be an option.

Although I’m fairly new at Magento, getting into the DB code / config seems overkill. I also wanted to stay away from JS only because it seems so logical to put this simple condition with the other rendering code in the template.

I’ve spent a lot of time on osCommerce lately where adding your own code seems fairly easy. Thanks for your suggestions everyone.

 
Magento Community Magento Community
Magento Community
Magento Community
 
rattler72
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2009-08-13
West Vancouver, BC Canada
 
dd_gi - 04 September 2009 02:32 AM

rattler72 - 03 September 2009 06:54 PM
dd_gi - 03 September 2009 05:31 PM
Try to mock up a screen shot of how you want it to look so I can see what you want exactly.

Here is what I’m trying to layout (see attached):


There are a set of radio buttons above.
Then a heading below that: “PERSONALIZED TEXT up to 6 lines”.
Then I have 6 lines of text fields below that.

These are all set up as options in my product.

To confirm, you have multiple text field options assigned to a product that you would like to group under the title “PERSONALIZED TEXT up to 6 lines” and then add “16 chars/line, uppercase” to each row under those options?  I assume that you would also like to transform the typed characters to uppercase and limit the characters per line to 16 with JS?  Do you allow any characters to be entered such as symbols etc. or do you have a specific subset of characters that you allow?

Yes, the main issue is grouping the text fields with a header.

Do not worry about the label “16 chars/line, uppercase” or limiting the number of characters… we took care of the label with css and Magento has settings for the character limit.

 
Magento Community Magento Community
Magento Community
Magento Community
 
rattler72
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2009-08-13
West Vancouver, BC Canada
 

Fantastic! I think that’ll be great. Thanks so much.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top