Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 10-02-2014, 10:11 AM
TheAdminMarket's Avatar
TheAdminMarket TheAdminMarket is offline
 
Join Date: Jun 2013
Location: Thessaloniki, Greece
Posts: 511
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just as idea, without testing anything:
Code:
<vb:if condition="in_array($type, $selectedtypes)"> checked</vb:if>
Edited: Seems that I'm out of topic. Have read only the last post and I thought that the code before was already working.
Reply With Quote
  #12  
Old 10-02-2014, 01:06 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think the problem is the preRegister statement, it should be like this:

PHP Code:
$parentarray explode(','$foruminfo[parentlist]); 
vB_Template::preRegister('FORUMDISPLAY', array('parentarray' => $parentarray)); 
Reply With Quote
  #13  
Old 10-02-2014, 07:20 PM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I think the problem is the preRegister statement, it should be like this:
Good eye! Yep, preregister variables are merged into an existing array with the template name being the key. So it must be in an array. I was concentrating on the compilation problem, so I didn't even notice. Thanks, I would have missed it.

The current problem, is the parsing of the vbulletin conditional when using safe_function "in_array" -- it is failing validation. I have fixed this problem at work so when I get a chance I am going to snoop at my code.

With your fix, his code should work, if he forces a save of the template.
Reply With Quote
  #14  
Old 10-02-2014, 11:23 PM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tbworld View Post
In line (78) of template search_common.

Code:
   <vb:if condition="in_array($type, $selectedtypes)"> checked="checked"</vb:if>
vb4.2.1 it parses.
vb4.2.2 it fails.

Does the conditional work correctly, if you force the saving of the template?
I can't force save for some reason. When I click 'Continue' on the validation error page, it takes me to a page that says 'This template was changed by someone else while you were editing it. YOUR CHANGES HAVE NOT BEEN SAVED ...'. It has the two windows to merge the original with the edited version, so I move the conditional statement into the window I want to save, I click 'Save and Reload'. It then comes up with the original validation error screen with the 'Continue' or 'Go Back', and if I click 'Continue' it comes up with the 'This template was changed .....' again.

I know nobody else is editing anything. So not sure what is going on there.

I have also updated my plugin to what was suggested above - thanks for that!

I also have that conditional you found in the search_common templace, so that would mean that vBulletin does accept it? Or it's just forced a save?

Thanks for your help everyone.

Cheers

--------------- Added [DATE]1412297432[/DATE] at [TIME]1412297432[/TIME] ---------------

I attempted to put the
Code:
<vb:if condition="in_array($type, $selectedtypes)"> checked="checked"</vb:if>
into my FORUMDISPLAY template, and that gets the validation error too.

Which is strange since it is being used in the search_common template.
Reply With Quote
  #15  
Old 10-03-2014, 12:23 AM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by hilaryl View Post

I also have that conditional you found in the search_common templace, so that would mean that vBulletin does accept it? Or it's just forced a save?

Which is strange since it is being used in the search_common template.
There is only one use of "in_array" in all the templates that matches your use and it fails validation. I had to force save the template.

---------------------------------------------------------

Quote:
I can't force save for some reason. When I click 'Continue' on the validation error page, it takes me to a page that says 'This template was changed by someone else while you were editing it.
That error will vacate when the invalid session times out.

Let me know if you still have trouble forcing the save of the template. I do have this problem resolved on my main systems (something I fixed a long time ago), but the code cannot easily be ported and would make you non vb standard, so I am working on a easy circumvent for the problem.
Reply With Quote
  #16  
Old 10-03-2014, 01:28 AM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tbworld View Post
That error will vacate when the invalid session times out.
How long does an invalid session take to time out?

I attempted this first yesterday, and then tried it first thing today, and it still came up with the 'Someone else is editing' message.

Thanks for your ongoing support.

Cheers
Reply With Quote
  #17  
Old 10-08-2014, 10:54 PM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tbworld View Post
I do have this problem resolved on my main systems (something I fixed a long time ago), but the code cannot easily be ported and would make you non vb standard, so I am working on a easy circumvent for the problem.
How did you go with finding an easy circumvent for this problem?

I still can't force save the template which is frustrating - always comes up with the 'Someone else is editing at the same time' message.

I'm trying to think if there's another way I can get the parentid that I need.

Thanks,
hilaryl
Reply With Quote
  #18  
Old 10-08-2014, 11:21 PM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In my own code, I fixed some small issues with the lexer, some minor issues with the parsers, and beefed up some error routines. Most of these issues were found due to us extending the templating system. The average user has probably never run into any of these issues, unless they have used the templating system extensively. vBulletin allows you to force a save on almost all errors, it gets around the few validation problems on the stock conditionals, curly, and tag definitions. That was a smart move on their part.

I am not posting the other fixes. I doubt most users will want to alter their source files or have a need for the patches. At this point only someone expanding the templater system would be interested and they are welcome to contact me.

This particular fix will assist the beginner templater as single errors were not being displayed correctly. This did impact you with the safe-function "in_array".

Replace function in "/includes/function.php" with the new function below. Sorry, this cannot be done via a plugin.
PHP Code:
function fetch_error_array($errors)
{
    
$compiled_errors = array();

        
// TBWORLD - vBulletin.org - 2014.10.05
        //   Resolves one of the template erroneous compile errors and restores (broken) single error messages.
        //   This bug exists vBulletin v4.2.0 and earlier  --> 4.2.3.beta2.

        
if (!is_array($errors))
        {
            
$compiled_errors[] = $errors;
            return 
$compiled_errors;
        }
        else
        {    
            foreach (
$errors as $key => $value)
            {
                if (
is_string($value))
                {
                    
$compiled_errors[$key] = fetch_error($value);
                }
                else if (
is_array($value))
                {
                    
$compiled_errors[$key] = call_user_func_array('fetch_error'$value);
                }
            }
        }    
        return 
$compiled_errors;
    } 
Reply With Quote
  #19  
Old 10-09-2014, 01:10 AM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks tbworld.

Ideally we would like to do as little modifying as possible to the core files.

I have actually found a way that works better for what I am trying to achieve - and it validates in the template!

Instead of trying to compare the whole parentlist array (690,610,-1) I've created variables in the custom plugin that are assigned to specific keys in the array (each forum id level).

Code:
// Get the second last key in the array and assign it to a variable
$grandparent = $parentarray[count($parentarray)-2];
I do the same to get the third last key.

Now I can access the variable in my template like this
Code:
<vb:if condition="in_array($grandparent, array(13,62))"> It's working </vb:if>
This method seems to be exactly what am after, and the best part is I don't have to force save the templates.

Thanks for all your replies everyone. Talking it out and looking at the possible options has helped me understand better what I can do/need to do.

Thanks,
hilaryl
Reply With Quote
Благодарность от:
tbworld
  #20  
Old 10-10-2014, 12:32 AM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is some conditional usage that you may want to ponder. Of course all of this can and maybe should be done in PHP, but sometimes this is more fun. I discovered quite a few interesting things when enhancing the template system.

One of the things I modified in the template system is a 'break' for the 'each' conditional. I am pointing this out, because in the crazy example below the routine continues to iterate the array and we may have already found our resultant.

Code:
<vb:comment>
 Iterates an array for basically no reason, and if a value was found in the array
 the create a new variable inside the template for altering a dynamic response. (tbworld method)
</vb:comment>

<vb:each from="show" key="show_key" value="show_value">
    <vb:comment>
      <!-- Just to show usage -->
      key:   {vb:var show_key}  <br>
      value: {vb:var show_value}<br>
    </vb:comment>

    <!-- Check for existance of key in $show -->
    <vb:if condition="array_key_exists('member', $show)  AND  (!isset($newvar))">
        <div>Array Key Exists!</div>

        <!-- create or set a value to a variable --> 
        <vb:if condition="$newvar='Yes we created a new variable $newvar!'"></vb:if>
    </vb:if>  
</vb:each>

<!-- Display the new variable we just created -->
<dl>
   <dd>Did we create a new variable?</dd>
   <dt>{vb:raw newvar}</dt>
</dl>

<!-- --------------------------------------------------------------- -->

<!-- Key exists if not NULL -->
<vb:if condition="isset($show['member'])">--isset test --<br /></vb:if>  

<!-- Expansion on the above examples, Use with caution! -->

<!-- Create a new Array -->
<vb:if condition="$new_array = array('member', 'fruit', 'fish')" ></vb:if>

<!-- Create a new Key field variable  -->
<vb:if condition="$new_test_key='member'"></vb:if>

<!-- Create a variable resultant --> 
<vb:if condition="$resultant=in_array($new_array[$new_test_key], $show, false)" >Test Key exist in $show array<br /></vb:if>
Have fun.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:40 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05350 seconds
  • Memory Usage 2,290KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_code
  • (2)bbcode_php
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete