Jefferson49 / Joomla_plugin_sexypolling_reloaded

Migration of the joomla plugin "Sexy Polling" to joomla 4.x
GNU General Public License v3.0
2 stars 3 forks source link

Inserting a poll into an article using shortcode [sexypolling id="id"] #86

Closed JindraEkart closed 5 months ago

JindraEkart commented 5 months ago

I installed Sexy Polling Reloaded, v5.0.4.0 (for Joomla 4.x, 3.10) into Joomla version 3.10.12.

I set up a test poll in the module and in the article using a shortcode.

Everything works correctly in the module:
URL: https://testnove.silvarium.net/zpravy-z-oboru-lesnictvi-a-drevarstvi The only problem is that it doesn't load the width: 100% parameter from the poll settings, but instead sets a fixed width of the poll block, and that's not correct for a responsive website. This can be solved by overriding it in CSS.

In the article, the CSS for the poll template does not load, and when the results are displayed, the graph bars are not generated, color.js error. URL: https://testnove.silvarium.net/lesnictvi/budoucnost-je-ve-vetsim-propojeni-lesnictvi-a-zpracovani-drivi

Cannot read properties of undefined (reading '0') at jQuery.fx.step. (color.js:24:64) at fx.update (sexylib.js:4:22881) at fx.step (sexylib.js:4:24820) at h (sexylib.js:4:23149) at fx.custom (sexylib.js:4:23527) at HTMLDivElement.g (sexylib.js:4:21163) at Function.dequeue (sexylib.js:2:24179) at HTMLDivElement. (sexylib.js:2:24508) at Function.each (sexylib.js:2:11776) at init.each (sexylib.js:2:8304)

Best regards Jindrich Ekart

Jefferson49 commented 5 months ago

Hello Jindrich,

thank you for reporting your issues.

Everything works correctly in the module: URL: https://testnove.silvarium.net/zpravy-z-oboru-lesnictvi-a-drevarstvi The only problem is that it doesn't load the width: 100% parameter from the poll settings, but instead sets a fixed width of the poll block, and that's not correct for a responsive website. This can be solved by overriding it in CSS.

I am not sure about the width topic. For me, it looks like in the screenshot below, which seems to be o.k.. Does it look different in your browser? Can you mark the wrong width in a screenshot?

silvarium1

doesn't load the width: 100% parameter from the poll settings

I am not sure, which parameter do you refer to. A parameter in the template settings? Can you describe in more detail?

This can be solved by overriding it in CSS

Can you paste the CSS code, which seems to be wrong? What did you change to override it?

Jefferson49 commented 5 months ago

In the article, the CSS for the poll template does not load, and when the results are displayed, the graph bars are not generated, color.js error. URL: https://testnove.silvarium.net/lesnictvi/budoucnost-je-ve-vetsim-propojeni-lesnictvi-a-zpracovani-drivi

I can reproduce this. For me, it looks like this:

silvarium_bug2

Maybe, this issue looks a little bit simular to earlier issues #62, #63. They occurred, if a group of votes (i.e. "Polls" instead of "Single Poll") was shown in one site module. However, should be fixed in version 5.0.4.0. Are you sure you use 5.0.4.0?

To analyze the background, it would be very helpful if you could send me the Sexypolling tables from your database. These tables contain all the configuration and poll data from your installation. You can select the 5 tables in phpMyAdmin and export them to a SQL file. The 5 tables are shown in the following screenshot:

293150893-bd5ae9a7-1082-4d7b-8bdc-a2d69913ef85

You can ZIP the SQL file and attach it to this issue. If you do not want to share your data on Github, you can also send the SQL file by email to: sexypolling.reloaded(at)gmail.com

Jefferson49 commented 5 months ago

From your screenshot, I just saw that some of the Czech translation is missing:

translation

You can create a Czech language file and add it to the installation zip file: com_sexypolling\language\cs-CZ\cs-CZ.com_sexypolling.ini

You can copy an existing language file from \en-GB\en-GB.com_sexypolling.ini and rename it. Afterwards change the translation.

You also need to add the language file to the component XML file: com_sexypolling\sexypolling.xml

<languages folder="site">
        <language tag="cs-CZ">language/cs-CZ/cs-CZ.com_sexypolling.ini</language>
</languages>

If you would like to contribute to the project, you can send me the translation file and I will add it to the module code.

Jefferson49 commented 5 months ago

color.js error

Cannot read properties of undefined (reading '0') at jQuery.fx.step. (color.js:24:64)

From the information in this error message, the error seem to occur in the following line of code: https://github.com/Jefferson49/Joomla_plugin_sexypolling_reloaded/blob/joomla_5.x/com_sexypolling/site/assets/js/color.js#L24

Seemingly, some RGB values are calculated.

Could this be some color value from your template? Which template did you use? Did you change some color values?

JindraEkart commented 5 months ago

Hello

my version of component is 5.0.4.0: version

there is part of settings for test poll: Poll width: 100% poll-style-options

but the module will be generated with a fixed width of 353px: module poll code css

I solved this by overriding my own CSS: .polling_container_wrapper { width: 100%!important; }

The problem with the embedded poll using the shortcode is because the CSS file for the poll settings is not generated, it is this part of the code in the HEAD section:

CSS for poll in article

poll in article

I am attaching the table export for the component: tables-sexypollings.zip

Best regards Jindřich Ekart

Jefferson49 commented 5 months ago

Thanks a lot for the excellent explanation and screenshots! That is a huge help.

I can reproduce the "Poll width: 100%" issue on my own Joomla system with my own poll example. I also get a fixed value. At the moment, I do not understand why it does not use the setting from the component administration, because the code looks alright.

It will probably need some time to check in a debugging session.

Jefferson49 commented 5 months ago

The problem with the embedded poll using the shortcode is because the CSS file for the poll settings is not generated, it is this part of the code in the HEAD section:

The module uses an AJAX communication, which can also be seen from your screenshot (href="/index.php?option=com_ajax..."). With AJAX, a function in the Sexy Polling PHP code is called, which generates and returns the CSS.

For the AJAX communication, the Joomla Ajax Interface component (com_ajax) is used, which should be part of every Joomla installation.

Can you check if this component is available and activated in your Joomla installation? Could there be any other reason, why a http-call to this component would not work?

com_ajax

JindraEkart commented 5 months ago

It looks like the Ajax component is installed in here: ajax component

JindraEkart commented 5 months ago

I get this error when I try to activate the CSS generation link in HEAD: https://testnove.silvarium.net/index.php?option=com_ajax&module=sexypolling&method=generateCSS&format=raw?id_poll=2&module_id=10000

error-ajax

This means:: LogicException: Method generateCSSAjax does not exist.

According to this guide: https://docs.joomla.org/Using_Joomla_Ajax_Interface There should be a method (function) called generateCSSAjax in the helper.php file in the mod_sexypolling module, but it is not there.

Jefferson49 commented 5 months ago

There should be a method (function) called generateCSSAjax in the helper.php file in the mod_sexypolling module, but it is not there.

Yes, this is a bug. If the Sexypolling plugin is used, the generateCSS Ajax method is called "onAfterRender" and the related method is not available. I attached a new version of the extension, which is based on v5.0.4.0 and includes a bugfix.

com_sexypolling_5.0.4.0_4e628417.zip

However, I cannot test the bugfix, because I cannot reproduce the behavior in my own installation.

Can you paste the exact way how you include the module in your site? For example, something like include "{loadmoduleid xyz}" in an article?

Do you use any specific things around the SexyPolling plugin and onAfterRender?

Could you install the bugfix and test if it fixes your issue?

Jefferson49 commented 5 months ago

However, I cannot test the bugfix, because I cannot reproduce the behavior in my own installation.

Now, I could reproduce the issue by inserting [sexypolling id="1"] into an article. From the Github issue title, I guess that's the same way how you use the module. Seemingly, this triggers the plugin and causes the specific behavior.

Seemingly, the attached bugfix is not sufficient. I will need to further investigate this issue.

As a workaround, you can load the module in the article in a different way: {loadmoduleid xyz}

JindraEkart commented 5 months ago

Hello

yes, as written in the title of the issue, the article contains a poll using the shortcode [sexypolling id="2"]. I thought this shortcode was meant to be inserted into an article using a plugin.

shortcode

I know that it is possible to insert a module into the article, but I am looking for polls that can be inserted into the article using a plugin (shortcode). We are looking for a solution that is suitable for editors who are not very experienced in coding. If the module were to be inserted into the article, someone must first create a module for each poll, and that is not very practical with a large number of polls.

We run a news site where multiple editors post articles and we are looking for a replacement for this component (Advanced Poll by Extore): https://extstore.com/joomla-extensions/components/advanced-pol

This component has not been updated for a long time and we have a problem with jQuery conflict, the polls do not work reliably for us.

I also have an idea for improving the Sexy polling component:

  1. The option to copy the poll (or copy the poll settings) is missing here, it will speed up the setting of the same or similar poll.
  2. In the global settings, there could be more default settings for polls, so that every new poll would not have to be set up again. The new poll would take the default settings from the global settings.
  3. If the shortcode poll embedding issue is resolved, a button plugin for the editor to embed the poll into the article would help.
  4. Option to turn off animations in polls (global property, poll property)
  5. Possibility to turn off the reordering of results according to the number of poll votes, not everyone wants it (global property, poll property)

Best regards Jindrich Ekart

Jefferson49 commented 5 months ago

Now, I managed to fixed the issue with shortcode [sexypolling id="id"].

If you want to test, you can use the attached version.

com_sexypolling_v5.0.4.0_5890b4e3.zip

Jefferson49 commented 5 months ago

I can reproduce the "Poll width: 100%" issue on my own Joomla system with my own poll example. I also get a fixed value. At the moment, I do not understand why it does not use the setting from the component administration, because the code looks alright.

I created a separate issue for this => #87

Jefferson49 commented 5 months ago

The option to copy the poll (or copy the poll settings) is missing here, it will speed up the setting of the same or similar poll.

I created a new issue for an enhancement => 88

Jefferson49 commented 5 months ago

In the global settings, there could be more default settings for polls, so that every new poll would not have to be set up again. The new poll would take the default settings from the global settings.

That would be more difficult, since the poll settings follow a certain standard Joomla structure. The shown settings are generated by the Joomla framework from this XML file: https://github.com/Jefferson49/Joomla_plugin_sexypolling_reloaded/blob/joomla_5.x/com_sexypolling/admin/models/forms/sexypoll.xml

The default settings for each new poll are contained as strings in this XML file. It would need a new concept to change that.

If copying of polls would be possible, a "default" poll could be created and all inherited polls could be created as a copy of this default poll? Do you think this would be sufficient?

Jefferson49 commented 5 months ago

If the shortcode poll embedding issue is resolved, a button plugin for the editor to embed the poll into the article would help.

I have no experience in this area. Is there some API available to add buttons to the WYSIWIG editor for articles?

Jefferson49 commented 5 months ago

Option to turn off animations in polls (global property, poll property)

Possibility to turn off the reordering of results according to the number of poll votes, not everyone wants it (global property, poll property)

Those issues are mostly performed in the JavaScript part of the code. In a brief check, I did not see a configuration parameter which is handed over from PHP to JavaScript.

Since starting with the maintenance of SexyPolling, I followed the strategy to keep the JavaScript as it is.

Jefferson49 commented 5 months ago

Reopened to continue discussion

Jefferson49 commented 5 months ago

The topic about the width is a little bit weired. The width is correctly handled within PHP and the html is generated with width=100%. However, after loading the page, a function in JavaScript overrides this setting and inserts the current width in pixels:

                $(".polling_container_wrapper").each(function() {
                    var w = $(this).width();
                    $(this).css("width",w);
                    var curr_h = $(this).find('.answer_wrapper').height();
                    $(this).find('.answer_wrapper').attr("h",curr_h);
                });

If I delete the line with $(this).css("width",w), the width keeps at 100%

At the moment, I do not know what is best. Deleting seems to help, but creates the risk that this line of code has some intention and will lead to unintended behavior if deleted. However, so far there seems to be no effect.

JindraEkart commented 5 months ago

Hello

I installed the patched version on the test site: com_sexypolling_v5.0.4.0_5890b4e3.zip. Now the CSS code for the poll is generated fine, so the poll is working: https://testnove.silvarium.net/lesnictvi/budoucnost-je-ve-vetsim-propojeni-lesnictvi-a-zpracovani-drivi

It's also great news that a new feature will be added - poll copy.

Thank you for the excellent work.

Best regards Jindřich Ekart

Jefferson49 commented 5 months ago

Regarding copying of polls, I managed to include "Save as Copy" in the poll view, which was quite simple. I also tried to add "Copy" in the polls view, which is not working yet and is more complicated than expected. See screenshot in #88.

The attachement contains a version with bugfix for width and "Save as Copy" in the poll view.

com_sexypolling_v5.0.4_dfd51377.zip

JindraEkart commented 5 months ago

Hello

It is not possible download this file (The attachement contains a version with bugfix for width and "Save as Copy" in the poll view): com_sexypolling_v5.0.4_dfd51377.zip https://github.com/Jefferson49/Joomla_plugin_sexypolling_reloaded/files/14490930/com_sexypolling_v5.0.4_dfd51377.zip

Best regards Jindrich Ekart

From: Jefferson49 @. Sent: Tuesday, March 05, 2024 6:43 AM To: Jefferson49/Joomla_plugin_sexypolling_reloaded @.> Cc: Jindřich Ekart @.>; Author @.> Subject: Re: [Jefferson49/Joomla_plugin_sexypolling_reloaded] Inserting a poll into an article using shortcode [sexypolling id="id"] (Issue #86)

Regarding copying of polls, I managed to include "Save as Copy" in the poll view, which was quite simple. I also tried to add "Copy" in the polls view, which is not working yet and is more complicated than expected. See screenshot in #88 https://github.com/Jefferson49/Joomla_plugin_sexypolling_reloaded/issues/88 .

The attachement contains a version with bugfix for width and "Save as Copy" in the poll view.

com_sexypolling_v5.0.4_dfd51377.zip https://github.com/Jefferson49/Joomla_plugin_sexypolling_reloaded/files/14490930/com_sexypolling_v5.0.4_dfd51377.zip

— Reply to this email directly, view it on GitHub https://github.com/Jefferson49/Joomla_plugin_sexypolling_reloaded/issues/86#issuecomment-1978007828 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BGQ6AW2M37IRMMSJXMCF6SDYWVLO5AVCNFSM6AAAAABD6A7KTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZYGAYDOOBSHA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/BGQ6AW2R5NH3GYYRCNHWEJLYWVLO5A5CNFSM6AAAAABD6A7KTWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTV4YARI.gif Message ID: @. @.> >

Jefferson49 commented 5 months ago

It is not possible download this file

I do not know what happened here. Maybe, a temporary problem, because it works for me.

In the mean time, I was able to add a copy feature to the poll view and to the polls view as well. The attachement contains the copy features and the width bugfix. I hope it works this time.

com_sexypolling_v5.0.4_dca23b82.zip

JindraEkart commented 5 months ago

Hello

Yes, the file has already been downloaded.

Copying the poll works fine.

Thank you, very good work :)

I will also process the Czech translation for this component and send it to you.

Best regards Jindrich Ekart

From: Jefferson49 @. Sent: Tuesday, March 05, 2024 9:58 PM To: Jefferson49/Joomla_plugin_sexypolling_reloaded @.> Cc: Jindřich Ekart @.>; Author @.> Subject: Re: [Jefferson49/Joomla_plugin_sexypolling_reloaded] Inserting a poll into an article using shortcode [sexypolling id="id"] (Issue #86)

It is not possible download this file

I do not know what happened here. Maybe, a temporary problem, because it works for me.

In the mean time, I was able to add a copy feature to the poll view and to the polls view as well. The attachement contains the copy features and the width bugfix. I hope it works this time.

com_sexypolling_v5.0.4_dca23b82.zip https://github.com/Jefferson49/Joomla_plugin_sexypolling_reloaded/files/14501464/com_sexypolling_v5.0.4_dca23b82.zip

— Reply to this email directly, view it on GitHub https://github.com/Jefferson49/Joomla_plugin_sexypolling_reloaded/issues/86#issuecomment-1979624321 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BGQ6AW3OD332QIURXNEGWXLYWYWVTAVCNFSM6AAAAABD6A7KTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZZGYZDIMZSGE . You are receiving this because you authored the thread. https://github.com/notifications/beacon/BGQ6AW2XUR7CEWJK55IBQWDYWYWVTA5CNFSM6AAAAABD6A7KTWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTV72VYC.gif Message ID: @. @.> >

Jefferson49 commented 5 months ago

Implemented the issue in title (#86) with https://github.com/Jefferson49/Joomla_plugin_sexypolling_reloaded/commit/5890b4e3d5b3a226b9e19ab7083b7022aa47c789.

Solved further issues and proposed new features within separate issues: #87, #88, #89.

Jefferson49 commented 5 months ago

I published a new release 5.0.5.0/5.5.0, which includes the new features as discussed.