Post by gifstv88 » Tue Apr 05, 2022 10:54 pm

Hello,
How could i make the Option Value Name to show on hovering instead of just text next to the option ?
Image
I am using OpenCart 3.0.2.0 - default theme - i tried something in product.twig and stylesheet.css but without succes .
Tried to modify product.twig on line 188

Newbie

Posts

Joined
Tue Apr 05, 2022 10:48 pm

Post by straightlight » Tue Apr 05, 2022 11:35 pm

gifstv88 wrote:
Tue Apr 05, 2022 10:54 pm
Hello,
How could i make the Option Value Name to show on hovering instead of just text next to the option ?
Image
I am using OpenCart 3.0.2.0 - default theme - i tried something in product.twig and stylesheet.css but without succes .
Tried to modify product.twig on line 188
Something was tried. Code unprovided.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by gifstv88 » Tue Apr 05, 2022 11:51 pm

I,m not a developer ,but i,m learning.

product.twing -

<div class="name_show[{{ option_value.name }}] /div>

stylesheet.css

.name_show {position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}

.name_show {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -5px;
left: 105%;
}

.name_show {
visibility: visible;
}

Newbie

Posts

Joined
Tue Apr 05, 2022 10:48 pm

Post by straightlight » Wed Apr 06, 2022 12:01 am

gifstv88 wrote:
Tue Apr 05, 2022 11:51 pm
I,m not a developer ,but i,m learning.

product.twing -

<div class="name_show[{{ option_value.name }}] /div>

stylesheet.css

.name_show {position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}

.name_show {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -5px;
left: 105%;
}

.name_show {
visibility: visible;
}
You could also create a new service request in the Commercial Support section of the forum to develop your projects as a custom job.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by mikeinterserv » Wed Apr 06, 2022 12:58 am

You can use this and adapt it.
You can use the title attribute also.

Code: Select all

 <img src="{{ option_value.image }}" title="{{ option_value.name }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" />

Style

Code: Select all

<style>
.hoverdiv {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black;
}

.hoverdiv .hovertext {
  visibility: hidden;
  width: 120px;
  background-color: black;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;


  /* Position hover text */
      top: 50px;
  right: 50%;
  position: absolute;
  z-index: 1;
}

.hoverdiv:hover .hovertext {
  visibility: visible;
}
</style>
Then you can add a span tag to your options images

Code: Select all

<div class="hoverdiv">Hover over me
  <span class="hovertext">This is the text that will display{{ option_value.name }}</span>
  <img src="my.jpg" alt="my image" title="my image" class="img-responsive">
</div>
You need to make the DIV as well.
The divs and spans then need adding to the options code in the product twig.
There you can the pickup the option VALUE name or whatever you want.
Once its working how you like you then need to POSITION the hover text to suit.

I will make an extension for it if you like :-)

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by gifstv88 » Wed Apr 06, 2022 1:26 am

Please do to have as a back up in the future
Thank you for you time

I started a new thread because straightlight suggested - "You could also create a new service request in the Commercial Support section of the forum to develop your projects as a custom job."

Newbie

Posts

Joined
Tue Apr 05, 2022 10:48 pm

Post by straightlight » Wed Apr 06, 2022 1:31 am

gifstv88 wrote:
Wed Apr 06, 2022 1:26 am
Please do to have as a back up in the future
Thank you for you time

I started a new thread because straightlight suggested - "You could also create a new service request in the Commercial Support section of the forum to develop your projects as a custom job."
There is absolutely nothing wrong with that reply as there are no reason to duplicate a request as it is differed from the forum rules. Suggesting OP users to create service requests on the forum is also implicit in the forum rules when it comes to custom codes.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by mikeinterserv » Wed Apr 06, 2022 1:44 am

gifstv88 wrote:
Wed Apr 06, 2022 1:26 am
Please do to have as a back up in the future
Thank you for you time
No worries it is a very simple extension.
I will post it here when I have done it. FREE

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by xxvirusxx » Wed Apr 06, 2022 1:59 am

Change this

Code: Select all

            {% if option.type == 'radio' %}
            <div class="form-group{% if option.required %} required {% endif %}">
              <label class="control-label">{{ option.name }}</label>
              <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %}
                <div class="radio">
                  <label>
                    <input type="radio" name="option[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" />
                    {% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> {% endif %}                  
                    {{ option_value.name }}
                    {% if option_value.price %}
                    ({{ option_value.price_prefix }}{{ option_value.price }})
                    {% endif %} </label>
                </div>
                {% endfor %} </div>
            </div>
            {% endif %}
To this

Code: Select all

            {% if option.type == 'radio' %}
            <div class="form-group{% if option.required %} required {% endif %}">
              <label class="control-label">{{ option.name }}</label>
              <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %}
                <div class="radio">
                  <label>
                    <input type="radio" name="option[{{ option.product_option_id }}]" value="{{ option_value.product_option_value_id }}" />
                    {% if option_value.image %}
                     <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" title ="{{ option_value.name }} {% if option_value.price %}({{ option_value.price_prefix }}{{ option_value.price }}){% endif %}" class="img-thumbnail" />
                    {% endif %}                  
                  </label>
                </div>
                {% endfor %}
              </div>
            </div>
            {% endif %}
Refresh ocmod modifications, clear theme cache, sass cache

Attachments

and_voila.png

and_voila.png (41.49 KiB) Viewed 1391 times


Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by cyclops12 » Wed Apr 06, 2022 2:08 am

You could change in your product.twig this :

Code: Select all

{% if option_value.image %} <img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> {% endif %}                  
                    {{ option_value.name }}
To this:

Code: Select all

{% if option_value.image %} <spanshow><img src="{{ option_value.image }}" alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}" class="img-thumbnail" /> </spanshow>{% endif %}                  
                    <newshow> {{ option_value.name }} </newshow>
Then just add this to the bottom of your css file:

Code: Select all

newshow {
  
  padding: 20px;
  display: none;
}
  
spanshow:hover + newshow {
  display: inline-block;
}

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by cyclops12 » Wed Apr 06, 2022 2:09 am

:laugh: :laugh: :laugh: there you go plenty of options

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by gifstv88 » Wed Apr 06, 2022 2:21 am

xxvirusxx - Multumesc frumos de ajutor :) raman dator cu bere

Thank you all for your help !

Newbie

Posts

Joined
Tue Apr 05, 2022 10:48 pm

Post by mikeinterserv » Wed Apr 06, 2022 7:30 am

Here is a nice css styled version
Its an installable module based on events.
After install can be installed uninstalled from extensions > modules > Option Image Hover Txt

Attachments

Last edited by mikeinterserv on Wed Apr 06, 2022 8:43 am, edited 2 times in total.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by straightlight » Wed Apr 06, 2022 8:28 am

mikeinterserv wrote:
Wed Apr 06, 2022 7:30 am
Here is a nice css styled version
Its an installable module based on events.
After install can be installed uninstalled from extensions > modules > Option Image Hover Txt
Other than the code structure and method block alignments, seems to be fine. However:
//author: mwinterserv
Isn't that a different username in the title as the one you're using since you're posting this package on the topic? ...

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Wed Apr 06, 2022 8:32 am

As for this line in the catalog controller:

Code: Select all

'href'  => 'catalog/view/theme/default/stylesheet/optionsimagehovertxt.css',
shouldn't it be:

Code: Select all

'href'  => 'catalog/view/theme/' . $this->getTheme() . '/stylesheet/optionsimagehovertxt.css',
?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by mikeinterserv » Wed Apr 06, 2022 8:34 am

straightlight wrote:
Wed Apr 06, 2022 8:32 am
As for this line in the catalog controller:

Code: Select all

'href'  => 'catalog/view/theme/default/stylesheet/optionsimagehovertxt.css',
shouldn't it be:

Code: Select all

'href'  => 'catalog/view/theme/' . $this->getTheme() . '/stylesheet/optionsimagehovertxt.css',
?
Probably :-)
So I changed it. I appreciate the tip because I completely forgot that. Remnants of testing.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by mikeinterserv » Wed Apr 06, 2022 8:41 am

straightlight wrote:
Wed Apr 06, 2022 8:28 am
Isn't that a different username in the title as the one you're using since you're posting this package on the topic? ...
Yep
So I changed it :-)
I like to make everyone happy me.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by straightlight » Wed Apr 06, 2022 8:45 am

mikeinterserv wrote:
Wed Apr 06, 2022 8:41 am
straightlight wrote:
Wed Apr 06, 2022 8:28 am
Isn't that a different username in the title as the one you're using since you're posting this package on the topic? ...
Yep
So I changed it :-)
I like to make everyone happy me.
A bit more alignment and Events identification with comments as per the core. Also added the $this->getTheme() in the styles array.

Attachments

Last edited by straightlight on Wed Apr 06, 2022 10:35 pm, edited 2 times in total.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by xxvirusxx » Wed Apr 06, 2022 2:30 pm

This part is not removed..

Code: Select all

                    {{ option_value.name }}
                    {% if option_value.price %}
                    ({{ option_value.price_prefix }}{{ option_value.price }})
                    {% endif %}

Attachments

this_part.png

this_part.png (25.17 KiB) Viewed 1198 times


Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by straightlight » Wed Apr 06, 2022 7:02 pm

xxvirusxx wrote:
Wed Apr 06, 2022 2:30 pm
This part is not removed..

Code: Select all

                    {{ option_value.name }}
                    {% if option_value.price %}
                    ({{ option_value.price_prefix }}{{ option_value.price }})
                    {% endif %}
Perhaps a $this->load->view should be used in case web designers needs to modify the HTML output ...

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: mandom and 43 guests