Version of OpenCart: 1.5.0.5
Clean install.
Hi guys!
I've been working on a site for our business using OC for the last 2 weeks and things are going well. I had to start again to take advantage of OC1.5 but that was cool as by the time we switched I had a good handle on the system.
For the first time though I've stumbled across an issue that I can't find a resolution to via the forums and the docs. I'm guessing I'm typing the wrong search keywords so apologies if this has been covered already:)
I have created an "Attribute" called "Vendor Info Link" and when adding a new product we add into this attribute text field a URL to the product manufacturer's product page. Of course when this is displayed on our sites product page under the "Specifications " tab it shows up as text rather than a clickable link.
I then added "a href" tags around the url in the attribute field for the product but it still print as text including the html I added.
I could hard code href tags into "product.tpl at around line 229 but that will affect all our different attribute types.
Is there a way to do this I haven't thought of short of hacking core or using an "extension"?
If an extension is the simple option here can anyone recommend a good one?
Thanks for any feedback. These forums and it's contributers are much appreciated!
Lars
Clean install.
Hi guys!
I've been working on a site for our business using OC for the last 2 weeks and things are going well. I had to start again to take advantage of OC1.5 but that was cool as by the time we switched I had a good handle on the system.
For the first time though I've stumbled across an issue that I can't find a resolution to via the forums and the docs. I'm guessing I'm typing the wrong search keywords so apologies if this has been covered already:)
I have created an "Attribute" called "Vendor Info Link" and when adding a new product we add into this attribute text field a URL to the product manufacturer's product page. Of course when this is displayed on our sites product page under the "Specifications " tab it shows up as text rather than a clickable link.
I then added "a href" tags around the url in the attribute field for the product but it still print as text including the html I added.
I could hard code href tags into "product.tpl at around line 229 but that will affect all our different attribute types.
Is there a way to do this I haven't thought of short of hacking core or using an "extension"?
If an extension is the simple option here can anyone recommend a good one?
Thanks for any feedback. These forums and it's contributers are much appreciated!
Lars
Last edited by ModPC on Thu Jun 23, 2011 5:26 am, edited 4 times in total.
I'm an OC noob!
if you can find the attribute id for that particular attribute. then you can edit product.tpl where it pulls attributes and do something like
That assumes your attribute id is 0, but it could be anything.
Not sure if this code is exactly right but something along these lines it what would make it work.
Code: Select all
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<?php if ($attribute['attribute_id'] = 0) { ?>
<tr>
<td><a href="<?php echo $attribute['text']; ?>"><?php echo $attribute['name']; ?></a></td>
</tr>
<?php } else { ?>
<tr>
<td><?php echo $attribute['name']; ?></td>
<td><?php echo $attribute['text']; ?></td>
</tr>
<?php } ?>
Not sure if this code is exactly right but something along these lines it what would make it work.
That works great SXguy, cheers for that.
I'll post my mod of your example as there was a curly bracket missing (last line of example code) throwing a "unexpected $end" error.
Lars
I'll post my mod of your example as there was a curly bracket missing (last line of example code) throwing a "unexpected $end" error.
Code: Select all
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<?php if ($attribute['attribute_id'] = 12) { ?>
<tr>
<td><?php echo $attribute['name']; ?></td>
<td><a href="<?php echo $attribute['text']; ?>"><?php echo $attribute['text']; ?></a></td>
</tr>
<?php } else { ?>
<tr>
<td><?php echo $attribute['name']; ?></td>
<td><?php echo $attribute['text']; ?></td>
</tr>
<?php }} ?>
Last edited by ModPC on Wed Jun 22, 2011 7:54 pm, edited 1 time in total.
I'm an OC noob!
I've just discovered, after adding another attribute, that the system is now hyperlinking every attribute regardless of it's "attribute_id".
So there's something wrong there:(
I'm too pooped to work it out this time of the night so maybe a php guru can have a look while I count sheep:)
I'll try again tomorrow.
So there's something wrong there:(
I'm too pooped to work it out this time of the night so maybe a php guru can have a look while I count sheep:)
I'll try again tomorrow.
I'm an OC noob!
ok i figured it out 
it was just missing another "=" lol
I think i will try to write a mod which will allow you to add a link as an attribute rather than mod it in this way.

it was just missing another "=" lol
Code: Select all
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<?php if ($attribute['attribute_id'] == 12) { ?>
<tr>
<td><?php echo $attribute['name']; ?></td>
<td><a href="<?php echo $attribute['text']; ?>"><?php echo $attribute['text']; ?></a></td>
</tr>
<?php } else { ?>
<tr>
<td><?php echo $attribute['name']; ?></td>
<td><?php echo $attribute['text']; ?></td>
</tr>
<?php } ?>
<?php } ?>
Hello,
Would anyone be able to help me with the exact code to use if I only want to show one attribute group and all the attribute under that particular group to be links. Other 'attribute group' should then not show. Here's what I tried to do and other tweaking of that but nothing seems to work yet. Thank you all in advance!
Would anyone be able to help me with the exact code to use if I only want to show one attribute group and all the attribute under that particular group to be links. Other 'attribute group' should then not show. Here's what I tried to do and other tweaking of that but nothing seems to work yet. Thank you all in advance!
Code: Select all
<?php if ($attribute_groups): ?>
<ul>
<?php foreach ($attribute_groups as $attribute_group) { ?>
<?php if ($attribute_group['attribute_group_id'] == 4) { ?>
<?php foreach ($attribute_group['attribute'] as $attribute): ?>
<li><a href="<?php echo $attribute['text']; ?>" target="_blank"><?php echo $attribute['name']; ?></a></li>
<?php } else { ?>
<div style="display: none;"></div>
<?php } ?>
<?php endforeach; ?>
<?php } ?>
<?php } ?>
</ul>
<?php endif; ?>
Who is online
Users browsing this forum: No registered users and 24 guests