I’m not sure why it’s adding the slash or putting empty ones in between either.
What I am trying to get it to do is to assign id="div1" (with 1 being a variable) to all the <tr> tags within the fieldset with the id="carriers_mutliflat" ... it is only adding the tags to that fieldset, so I know I got that part right, but something with assigning it to the <tr> tags is not working properly. I’m sure this is a simple oversight ... can anyone point me in the right direction?
within “if” statements, you need to test with an “is equal” oporator, for instance
if($apple = 'yummy') {
}
Will test if $apple was successfully assigned the string “yummy” while
if($apple == 'yummy') {
}
will test if $apple IS ‘yummy’
so…
for($i = 0; $i <= 100; $i++) { if ($element->getHtmlId() == "carriers_multiflat") { if ($html == '<tr>') { $html.= '<tr id="'.div.$i.'">'; //this sytnax is going to give you an error when PHP doesn't find a constant "div" - you need to do $html = '<tr id="div' . $i . '"> } } } //this still will not work, because $html does not equal just "<tr>" but might contain that tag somewhere.
check out php.net - has a lot of GOOD documentation
that’s a problem, because str_replace will replace ALL instance of what you are searching for (in your case, ‘<tr>’ with another string...so you can’t add a counter variable (such as $i i your case) that increments for each <tr> tag being replaced.
My confusion is how you are coming about this, as I’m sure there is another way to go about it.
Can you explain what files you are editing and to what final purpose? I think judging by this, you are editing a certain .phtml file?
If you can share your files or show the whole thing, I’d be glad to offer assistance
protected function _getCollapseState($element) { $extra = Mage::getSingleton('admin/session')->getUser()->getExtra(); if (isset($extra['configState'][$element->getId()])) { return $extra['configState'][$element->getId()]; } return false; } }
The reason is because I am trying to add a show/hide element within my shipping module xml so that I can show/hide the 10 different shipping options individually as needed. There seems to be no simple way to do this without assigning an id for the show/hide script to reference, which is why I was attempting to add it in the Fieldset.php file. As I showed in a previous post, I was getting it to work, but it was adding the <tr> tags instead of replacing the ones already there.
My original thought was to make a div surrounding all of method 1 (which all 3 of those belong to) to show/hide it, but I was going to settle for just using a show/hide on the details.
Does this help clarify? I really appreciate any way you can help as I have been stumbling through this for awhile now!
mmm i guess im still abit confused, but here’s my shot at trying to accomplish what you want (maybe )
for($i = 0; $i <= 40; $i++) { if ($element->getHtmlId() == "carriers_multiflat") { $html.= '<tr id="div'.$i.'"><td>something to go here??</td></tr>'; } }
So that will create 40 full rows (with one “cell") within that <tbody>. I don’t know what you want to do within that <tbody>...you need the opening and closing <tr> tags, a long with the <td> tags to make a complete table cell. (<tr>’s do the rows, <td>’s do the columns...each row will contain one or many column...not sure if you are familiar with it, im sure you are, but you never know )
I’m attaching a screen shot of my admin details - maybe that will help explain. See how there are 2 methods? There are actually 10, so I want to start out with (at the very least) the detail sections of each of them hidden (only showing the name and price fields) but have the ability to show them if they are needed. I can get it to show/hide anything on the lefthand column but I want to it to show/hide the whole row (both Details and the text area). My thought in this thread was that if I can get it to assign id’s to the <tr> tags I can use those id’s to show/hide with. An alternative method would be to somehow get it to set divs around that area, but I was having a more difficult time figuring that out in the xml.