Updating Old FAQ Addon

Open to all! Ask other shopowners for help.
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Re: Updating Old FAQ Addon

Post by radhavallabh »

tessthepup wrote: Sun Jan 29, 2023 5:39 pm @ecartz @raiwa

All sorted and fixed :D

Thanks for the help guys.

Would this be of interest to people as an addon if I was to upload it?
I shall be interested too dear as currently I need to put a accordian open close html code to each question for which the answer needs to be seen and it behaves very abnormally.....
Thank you in advance;
Very Warm Regds./
radhavallabh


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
tessthepup
Certified Developer
Posts: 383
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Updating Old FAQ Addon

Post by tessthepup »

ok got myself a little bit stuck on converting some old links. There are no errors thrown but the status links just do not work.

This is the old code

Code: Select all

<?php  
        if ($val['visible'] == 1) {
            echo '<i class="fas fa-circle dovisible"></i>&nbsp;&nbsp;
            <a href="' . tep_href_link('faq_manager.php', "faq_action=Visible&faq_id=$val[faq_id]&visible=$val[visible]") . '">
            <i class="fas fa-circle dohidden_lite"></i></a>';
        }else {
            echo '<a href="' . tep_href_link('faq_manager.php', "faq_action=Visible&faq_id=$val[faq_id]&visible=$val[visible]") . '">
            <i class="fas fa-circle dovisible_lite"></i>&nbsp;&nbsp;</a>		
            <i class="fas fa-circle dohidden"></i>';
        };
        ?>
and this is what I have

Code: Select all

<?php  
        if ($val['visible'] == 1) {
            echo '<i class="fas fa-circle dovisible"></i>&nbsp;&nbsp;
            <a href="' . $Admin->link('faq_manager.php', ['faq_action' => 'Visible&faq_id=$val[faq_id]&visible=$val[visible]']) . '">                        
            <i class="fas fa-circle dohidden_lite"></i></a>';
        }else {
            echo '<a href="' . $Admin->link('faq_manager.php', ['faq_action' => 'Visible&faq_id=$val[faq_id]&visible=$val[visible]']) . '">
            <i class="fas fa-circle dovisible_lite"></i>&nbsp;&nbsp;</a>		
            <i class="fas fa-circle dohidden"></i>';
        };
        ?>
You do not have the required permissions to view the files attached to this post.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Updating Old FAQ Addon

Post by ecartz »

Code: Select all

<?php
        $flag_link = $Admin->link('faq_manager.php', ['faq_action' => 'Visible', 'faq_id' => $val['faq_id'], 'visible' => $val['visible']]);
        if ($val['visible'] == 1) {
            echo <<<"EOHTML"
            <i class="fas fa-circle dovisible"></i>&nbsp;&nbsp;
            <a href="$flag_link">                        
            <i class="fas fa-circle dohidden_lite"></i></a>
EOHTML;
        }else {
            echo <<<"EOHTML"
            <a href="$flag_link">
            <i class="fas fa-circle dovisible_lite"></i>&nbsp;&nbsp;</a>		
            <i class="fas fa-circle dohidden"></i>
EOHTML;
        };
        ?>
User avatar
tessthepup
Certified Developer
Posts: 383
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Updating Old FAQ Addon

Post by tessthepup »

ecartz wrote: Sun Feb 05, 2023 7:16 pm

Code: Select all

<?php
        $flag_link = $Admin->link('faq_manager.php', ['faq_action' => 'Visible', 'faq_id' => $val['faq_id'], 'visible' => $val['visible']]);
        if ($val['visible'] == 1) {
            echo <<<"EOHTML"
            <i class="fas fa-circle dovisible"></i>&nbsp;&nbsp;
            <a href="$flag_link">                        
            <i class="fas fa-circle dohidden_lite"></i></a>
EOHTML;
        }else {
            echo <<<"EOHTML"
            <a href="$flag_link">
            <i class="fas fa-circle dovisible_lite"></i>&nbsp;&nbsp;</a>		
            <i class="fas fa-circle dohidden"></i>
EOHTML;
        };
        ?>
@ecartz

Hi Matt, I have been trying to replace tep_draw_form and looked and tried just about every example in core I could find but can not seem to get it to work.

Any chance of picking your brains again

Code: Select all

echo tep_draw_form('faq_manager','faq_manager.php', 'faq_action=Update');    
     echo tep_draw_hidden_field('faq_id', $faq_id);
Thanks

Mark
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Updating Old FAQ Addon

Post by ecartz »

Code: Select all

echo (new Form('faq_manager', $Admin->link('faq_manager.php', ['faq_action' => 'Update']))->hide('faq_id', $faq_id);
User avatar
tessthepup
Certified Developer
Posts: 383
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Updating Old FAQ Addon

Post by tessthepup »

ecartz wrote: Thu Feb 09, 2023 1:17 am

Code: Select all

echo (new Form('faq_manager', $Admin->link('faq_manager.php', ['faq_action' => 'Update']))->hide('faq_id', $faq_id);
@ecartz

Thanks Matt :D
User avatar
tessthepup
Certified Developer
Posts: 383
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Updating Old FAQ Addon

Post by tessthepup »

@ecartz

I think I am just about done in converting the old code to the new however I have these warnings which I have never seen before
PHP Notice: Array to string conversion in /home/store/public_html/includes/system/class_index.php on line 38

PHP Notice: Array to string conversion in /home/store/public_html/admin/includes/application_top.php on line 134
They only appear when saving a new FAQ and not editing then saving.

Would it be something to do with the way the language is handled on save? (only guessing)
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Updating Old FAQ Addon

Post by ecartz »

Look for something like

Code: Select all

foreach (language::load_all() as $language) {
User avatar
tessthepup
Certified Developer
Posts: 383
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Updating Old FAQ Addon

Post by tessthepup »

ecartz wrote: Thu Feb 09, 2023 11:01 pm Look for something like

Code: Select all

foreach (language::load_all() as $language) {
@ecartz

Thanks again Matt, all errors debugged apart from when testing on PHP 8.1 I get this error
PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in
This is the offending line

Code: Select all

if (count($languages) > 1) {
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Updating Old FAQ Addon

Post by ecartz »

That error would go away if you changed the line to

Code: Select all

if (is_array($languages) && (count($languages) > 1)) {
But a better solution might be to change whatever is setting $languages to be a string. Because it may have other side effects.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply