Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: Help with relative paths in includes.

  1. #11
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Yes, and the actual code is quite long and confusing. I was just looking for the array set up correctly and then called correctly in that spot.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #12
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I, too, fail to understand your question.

    Do you mean to set up something like this:
    Code:
    (condition1 ? array(option1, option2) : array(option3, option4))[condition2 ? 0 : 1];
    ... selecting between arrays of options, then further refining the selection with another ternary operator? This seems elegant, if inefficient.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #13
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Okay here is the section:

    PHP Code:
        foreach (array_keys($context['smileys']) as $location)
            
    $context['smileys'][$location] = array(
                
    'id' => $location,
                
    'title' => $location == 'postform' $txt['smileys_location_form'] : $txt['smileys_location_popup'],
                
    'description' => $location == 'postform' $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'],
                
    'last_row' => count($context['smileys'][$location]['rows']),
                
    'rows' => array_values($context['smileys'][$location]['rows']),
            ); 
    What I have done so far is to make 9 other pop ups. so the 'title' and 'description' is currently set up as an either : or situation.

    I wanted to make it either : or, or, or ...

    Looking for different ways to do this without having to rewrite the entire coding for 12 different php files.

    Looking at the post above, gave me the idea to have the "or" part be an array in itself. so it would be either : (array)

    where array would = or, or, or...
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #14
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I wanted to make it either : or, or, or ...
    Something like:
    Code:
    (condition1 ?
      either1 :
      (condition2 ?
        either2 :
        (condition3 ?
          or1
        )
      )
    )
    ?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #15
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Not quite. I apologize for being obtuse. I don't know how to explain it well I guess.

    Here is another attempt.

    PHP Code:
    'title' => $location == 'postform' $txt['smileys_location_form'] : $txt['smileys_location_popup'],
                
    'description' => $location == 'postform' $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], 
    What this script does, is shows a table. As it stands the table has 2 boxes inside it. The first is postform. the $txt part is the title of the postform's box. The other side of the : is the pop up box. (bt, the boxes contain a visual of what is contained in the actual post form and actual pop up).

    I have made a total of 10 boxes. In this case, the one postform, and then 9 popups.

    With the code as it is, the post form uses it's $txt as the title, but the other 9 'popup' boxes share the same $txt, so even though they are different they have the same title.

    What I am attempting is to make it so it says something like:

    PHP Code:
    'title' => $location == 'postform' $txt['smileys_location_form'] : $array,
                
    'description' => $location == 'postform' $txt['smileys_location_form_description'] : $array2
    Where I would define $array and $array2 as something like:

    PHP Code:
    $array = ($txt['smileys_location_popup'], $txt['smileys_location_popup_a'], $txt['smileys_location_popup_b'], $txt['smileys_location_popup_c'], ..etc), 
    In the hopes that the 9 pop up boxes in this table would then take on their own titles.

    Does that make sense?

    I know this is trial and error here, Which is why my original question was on the php code syntax, was it correct. Knowing if there were errors in the code would help when I get a parse error on the page. If I know the code is written correctly then I would know it wasn't that causing the errors.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #16
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    $i = 0;
    
    'title' => $location == 'postform' ? $txt['smileys_location_form'] : $array[$i++],
                'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $array2[$i++],
    Like that?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #17
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Code:
    'title' => $location == 'postform' ? $txt['smileys_location_form'] : $array[$i++],
                'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $array2[$i++],
    Shouldn't that comparison operator be === ? Comparing and assigning a value?
    - Mike

  8. #18
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Erm... no? === is for non-type-casting comparison. It could be used there, certainly, but no assignment is involved.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #19
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Oops. Sorry, I thought it was something else. I guess I'll have to do my reading
    - Mike

  10. #20
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Cool. I will try that out and let you know what happens.

    Thanks guys!
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •