Post by ModPC » Wed Jun 22, 2011 7:41 am

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
Last edited by ModPC on Thu Jun 23, 2011 5:26 am, edited 4 times in total.

I'm an OC noob!


Newbie

Posts

Joined
Fri Jun 10, 2011 10:50 am

Post by SXGuy » Wed Jun 22, 2011 5:04 pm

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

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 } ?>
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.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by ModPC » Wed Jun 22, 2011 7:00 pm

Mate, you are THE man! I'll sort this out and post result back here for the next bloke who wants to know this.

I'm an OC noob!


Newbie

Posts

Joined
Fri Jun 10, 2011 10:50 am

Post by ModPC » Wed Jun 22, 2011 7:25 pm

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.

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 }} ?>
Lars
Last edited by ModPC on Wed Jun 22, 2011 7:54 pm, edited 1 time in total.

I'm an OC noob!


Newbie

Posts

Joined
Fri Jun 10, 2011 10:50 am

Post by ModPC » Wed Jun 22, 2011 7:50 pm

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.

I'm an OC noob!


Newbie

Posts

Joined
Fri Jun 10, 2011 10:50 am

Post by SXGuy » Wed Jun 22, 2011 9:41 pm

ok i figured it out :)

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 } ?>
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.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by ModPC » Thu Jun 23, 2011 5:26 am

Nice one SXGuy. That works nice!

BTW, do you offer freelance OC work?

I'm an OC noob!


Newbie

Posts

Joined
Fri Jun 10, 2011 10:50 am

Post by SXGuy » Thu Jun 23, 2011 6:18 am

i do, depending on what you require. I dont mind doing bits and peices, but nothing thats too major as i currently have a few client projects on the go.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by ModPC » Thu Jun 23, 2011 9:27 am

Cool. I'll get in touch later on then. Thanks again!

I'm an OC noob!


Newbie

Posts

Joined
Fri Jun 10, 2011 10:50 am

Post by P2PCommon » Sat Aug 13, 2011 4:38 am

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!

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; ?>

Newbie

Posts

Joined
Fri Apr 22, 2011 12:28 am
Who is online

Users browsing this forum: No registered users and 24 guests