Adding content to tabs

  • Posts: 259
  • Thank you received: 10
4 years 11 months ago #317656

-- HikaShop version -- : 4.2.3

Tinkering with the display options, i've found the tabular view ideal for a clean look in the site in progress (considering the amount of text i need to add). I've succesfully added 3 tabs to the product display, by followind www.hikashop.com/support/documentation/106-faq.html#layo

if i'm doing this right that's at line 243 after the

<?php } ?>
The problem i'm currently facing is bifold

1. All tabs "work" besides the last one. If i click on the last one it "jumps" down from being tab title to looking like text. Clicking on the other tabs then keeps the title of the last tab present and in that position. It's no longer a tab see attachments
2. I have no idea how to add text to each seperate tab. There doesn't seam to be an option for that after doing this when adding/editing a product.

Adding content doesn't seem right to do it directly in the template. That would make the tabular content IDENTICAL for each and every product. I must be misunderstanding something here.

Attachments:
Last edit: 4 years 11 months ago by Ch3vr0n.

Please Log in or Create an account to join the conversation.

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 11 months ago #317657

Hi,

If you follow the instructions of the FAQ, your modifications will be saved in an override view file.
So you won't loose them when you update but you also won't get the future improvements we'll make in that view file.

Now regarding your first question, I'm not sure but I would say you made a mistake.
Regarding the second question, I've actually updated the FAQ to mention this as it's been asked several times so I think it's worth mentioning in the FAQ:

And if you want to display dynamic content in the tab, you can create a custom field of the table "product" via the menu Display>Custom fields (Essential and Business editions only). Then, you'll be able to enter the text you want in the custom field when you're editing your product.
And instead of <!-- Your div content --> in the previous code, you can use:
<?php echo $this->element->XXX;?>
where XXX is to be replaced by the column name of the custom product field.

The following user(s) said Thank You: Ch3vr0n

Please Log in or Create an account to join the conversation.

  • Posts: 259
  • Thank you received: 10
4 years 11 months ago #317674

i'll try that custom field method.

Assuming i read that correctly, in my case, for the second tab that would mean i need to make custom field of the table "product" with name "USE_ME" since USE_ME is the tab id for the tab with display name "USE.ME" (i found that using a . in the id caused problems)? and then in the view template instead of that DIV i would enter

<?php echo $this->element->USE_ME; ?>

is that correct?

Any idea's on why that last tab "jumps position"? I would be happy to provide back-end access.

Please Log in or Create an account to join the conversation.

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 10 months ago #317677

Hi,

I suppose yes.
I don't need a backend access for that.
What I need is:
- a link to the page with the issue
- a screenshot of the code you added in the view file.

The following user(s) said Thank You: Ch3vr0n

Please Log in or Create an account to join the conversation.

  • Posts: 259
  • Thank you received: 10
4 years 10 months ago #317701

access has been e-mailed

Please Log in or Create an account to join the conversation.

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 10 months ago #317712

Hi,

I checked your frontend but I can see two issues:
You use for example the id USE_ME_li in your first li tag. But it should be: hikashop_show_tabular_use_me_li

Also, you're missing completely the code:
<div class="hikashop_tabs_content" id="hikashop_show_tabular_use_me">
<?php echo $this->element->use_me; ?>
</div>
that you should put in the <ul class="hikashop_tabs_ul"> as explained in the FAQ.
That's because of these two things that the tabs don't work.

The following user(s) said Thank You: Ch3vr0n

Please Log in or Create an account to join the conversation.

  • Posts: 259
  • Thank you received: 10
4 years 10 months ago #317728

I understood the FAQ as that I'd needed to replace the entire ID. Not add the field ID after it. As to the 2nd part, that was intentional, I figured I'd try and get the tabs themselves working first, before adding actual content to it.

I'll try your fix this evening.

Please Log in or Create an account to join the conversation.

  • Posts: 259
  • Thank you received: 10
4 years 10 months ago #317771

Think i found a bug in the SQL routine. I initially didn't get it working so i deleted the custom field "use_me". The problem is when i tried to add it again, i was warned by Hikashop that the field already existed. But it didn't show in the list. So i ran a query on the database for the field name, and sure enough while the custom field got deleted from the LIST of custom fields, the matching entry in the table _hikashop_product did NOT get deleted and was still there.

I had to manually drop the field from the database table before i could add it again.

That said, still can't get it to work.

Custom field settings:
- label: USE.ME
- table: product
- column name: use_me
- field type: text (trying to add a plugin shortcode so it'll render a video)
- published: yes
- Display: Front-end: yes

It created an extra tab "Specificaties" on the front-end instead of using the tab "USE.ME" (with id hikashop_show_tabular_use_me_li) itself.

Now here's the kicker.

Adding the shortcode in only the "video" custom field > video isn't rendered
Adding the shortcode in any other custom field AND the video wysiwyg editor > video gets displayed

but still not in the proper tab

Last edit: 4 years 10 months ago by Ch3vr0n.

Please Log in or Create an account to join the conversation.

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 10 months ago #317797

Hi,

- You should turn off the display setting of your custom fields if you don't want them to appear in the specifications tab, since you're displaying them yourself
- you still had incorrect ids in your divs as they had an extra _li at the end of the id. That's why the tabs were not working
- also, you have variants in your product, so you need extra code to get the data from the main product
- also, since you want to replace tags from content plugins, you need extra code to process the content tags
I've done the modifications for you with the access you provided. Please note however that this goes way beyond user support. That's custom development work. If you need our help for similar things in the future, we'll have to charge you for that.

The following user(s) said Thank You: Ch3vr0n

Please Log in or Create an account to join the conversation.

  • Posts: 259
  • Thank you received: 10
4 years 10 months ago #317832

Oh you didn't have to do that nicholas. I'd have been happy to do this myself. Can you tell me what exactly it is you changed? That way i can make a backup of the needed code in a TXT file on my desktop so i have something to fall back on and won't have to bother you with this again :)

just compared my image with the current template code. Are you referring to this?

<?php echo JHTML::_('content.prepare',$main->use_me); ?>

If there were NO variants, then the default FAQ instructions of using
<?php echo $this->element->XXXX; ?>

would apply?

With content prepare this would become
<?php echo JHTML::_('content.prepare;$this->element->XXXX); ?>

Trying to get all angles here so i have everything in need for future usecases

As to the li part. I thought (or understood the instructions as) needing to copy the EXACT li id. But if i read you correctly this is incorrect? The _li is only used to tell hikashop it's an li but for the tab content section the _li from the tab id needs to be removed? Is that correct?

What about the custom field deletion i mentioned. Did i stumble on a bug?

Either way. Thanks for the excellent support, which deserves to be rewarded. Snapped up the PDF plugin and mollie.com paid addons. Maybe that will compensate a little for the time spent!

Last edit: 4 years 10 months ago by Ch3vr0n.

Please Log in or Create an account to join the conversation.

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 10 months ago #317834

Hi,

Yes, the code of the documentation would apply for products without variants and if you don't need content plugin replacement. We try to keep it simple for people not knowing much about code that's why the code in the FAQ doesn't handle edge cases.

Regarding the custom field deletion, it's not a bug. It's done on purpose so that if someone inadvertently delete the custom field, the data is not lost but still in the database. So you can always retrieve it by manually changing the namekey of the field in the hikashop_field table after creating a custom field with another column name.
And similarly, when you create a new custom field, we check that there isn't already a column with the name you want to use as it could break the system.

Thanks for the purchases !

Last edit: 4 years 10 months ago by nicolas.
The following user(s) said Thank You: Ch3vr0n

Please Log in or Create an account to join the conversation.

  • Posts: 259
  • Thank you received: 10
4 years 10 months ago #317915

Speaking of variants, just noticed setting up another product with variants that those tab fields are also there. Does this mean this whole 'mess' of pre-processing "main item" content could have been avoided if i had specified the data in the variants? (but considering some have upto 8-10 variants that would duplicate things a lot)

As to the custom field. Please tell me if i read you correctly

1. Delete custom field > field deleted from visible list, but db entry retained
2. creating new field with same id = error
3. Create new random field with some id
4. Look up the random column name in the db and change it to the one from (2)
5. data restored?

Please Log in or Create an account to join the conversation.

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 10 months ago #317928

Hi,

1. The thing is that in $this->element you have either: the data of the product if it has no variants, or the data of the default variant of the product.
So if you add the values you want in the custom fields of the default variant you could indeed always use $this->element.

2. No, it's not the column name of the field in the hikashop_product table that you need to change. It's the value of the field_namekey column for the custom field in the table hikashop_field that you need to change.

The following user(s) said Thank You: Ch3vr0n

Please Log in or Create an account to join the conversation.

  • Posts: 259
  • Thank you received: 10
4 years 10 months ago #317968

excellent. Thanks for the lessons. Greatly appreciated!

Some products don't have a video. Is there a way to hide a specific tab only on specific products?

Last edit: 4 years 10 months ago by Ch3vr0n.

Please Log in or Create an account to join the conversation.

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 10 months ago #318000

Sure.
You can add a condition around the li. That should be before:

<?php if(!empty($this->element->XXX)) { ?> 
And that should be after:
<?php } ?> 

Please Log in or Create an account to join the conversation.

  • Posts: 259
  • Thank you received: 10
4 years 10 months ago #318121

Looks like i missed that reply or would have replied sooner. I'll try that out real quick.

Perhaps also something to mention in the FAQ ;)

Please Log in or Create an account to join the conversation.

  • Posts: 259
  • Thank you received: 10
4 years 10 months ago #318408

So just tried this but i'm using variants with specifications in the main product remember

<?php if(!empty($main->video)) { ?>
          <li id="hikashop_show_tabular_video_li" class="hikashop_tabs_li ui-corner-top"><?php echo JText::_('VIDEO');?></li>
          <?php } ?>

Seems to be hiding the tab entirely, even for products WITH a video. Ideal option would be to surround the entire section of the 5 custom tabs with a php statement that would work on all tabs, and not require a specific statement for each li

I guess i could change from using the main to variant specific info but considering there's over 100 products, nearly each with 3 or more variants that's a bucketload of work.

Last edit: 4 years 10 months ago by Ch3vr0n.

Please Log in or Create an account to join the conversation.

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 10 months ago #318438

Hi,

Your code will display the "VIDEO" tab only if there is something in the custom field "video" of the main product.
I don't see why this wouldn't work.
I guess there is something you're not telling me about the situation. Like you actually want the tab to appear because you display several fields in that tab ?
In that case, you should add the check around the display of the custom field, and not around the tab title.
And around the tab title, you would need a more complex check to display the tab if at least one field is set.

The following user(s) said Thank You: Ch3vr0n

Please Log in or Create an account to join the conversation.

  • Posts: 259
  • Thank you received: 10
4 years 10 months ago #318462

Hey nicholas,

I only want the tab to appear IF the related custom field has been filled in. Any other case i want the tab hidden. I'm not using the variant specific custom field. Maybe that has something to do with it. Currently that code is hiding the video tab for ALL products including the ones that have video (including the ANGEL.MASQUE product being shown here www.hikashop.com/forum/product-category-...nagement.html#318461 )

(You can find that product under the category: Product type > Behandeling > top left one)

It's not a super big deal if what i'd like to do isn't possible without major customisation. It's just that i'd like not to show tabs for that specific product, if the tab has no data for that specific product.

1 last thing i tried is that i have front-end css file set to "default", so figured i'd set it back to "none" but that screws up the tabs completely. They still work, they're just no longer physical tabs.

Last edit: 4 years 10 months ago by Ch3vr0n.

Please Log in or Create an account to join the conversation.

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 10 months ago #318471

Hi,

Well, in that case, either your code is wrong, or the field is not empty for the product you're looking at.
Note that if you use a custom field of the type WYSIWYG, it's possible that your HTML editor adds extra HTML tags, even if you didn't enter anything in the field.
So try to check the type to "textarea" to see if that's the case. If so, it explains why you see the tab even though you believe it's empty.

The following user(s) said Thank You: Ch3vr0n

Please Log in or Create an account to join the conversation.

Time to create page: 0.093 seconds
Powered by Kunena Forum