We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38666
    • 98 Posts
    I have a resource that presents a visitor to our site with the option to search our members list by first letter of a member's surname or by province or state. (http://www.seedanalysts.ca/membership/members/). Searching by first letter of surname works in Firefox, Chrome and Internet Explorer. Searching by province or state works in Firefox but not in Chrome nor Internet Explorer. What I can't understand is why it won't render in Chrome and Internet Explorer. The same chunk is used in the surname search and display.
    The snippet:
    <?php
    $output = '';
    $csaacProv = $_GET[alpha];
    $csaacmember = $modx->getCollection('modUserProfile',array('state'=>$csaacProv ));
      
    foreach($csaacmember as $Pmembers) {
        /* get user ID from profile object */
        $userId = $Pmembers->get('internalKey');
     
        /* get extended fields */
        $data = $modx->getObject('userData', array('userdata_id' => $userId));
     
        $fields = array_merge ($Pmembers->toArray(), $data->toArray() );
     
        /* Set $fields['id'] to true user ID */
        $fields['id'] = $userId;
     
        $output .= $modx->getChunk('UsersProvTpl2', $fields);
    }
    return $output;
    

    The chunk:
    <p>
    <table width="400" border="1" cellspacing="2" cellpadding="2">
       <TR>
            <td colspan="2" bgcolor="#1D4429">
    		<STRONG><FONT color=#ffffff>[[+fullname]]</FONT></STRONG>
    	</td>
       </TR>
       <TR>
            <TD vAlign=top width="250" bgColor=#ffffff>
    		<FONT size=2><STRONG>[[+company]]</STRONG> <BR>[[+status]]</FONT> 
       	</TD>
    	<TD vAlign=top bgColor=#ffffff>
    		<FONT size=2>[[+address]]<BR>[[+city]], [[+state]]. <br>[[+zip]]</FONT>
    	</TD>
       </TR>
       <TR>
             <TD vAlign=top bgColor=#ffffff>
    		<FONT size=2>Ph: [[+phone]]<BR>Fax (Other):[[+fax]]<BR>
    		Email: <FONT size=3><A href="[[+email]]">
    		<FONT size=2>[[+email]]</FONT></A></FONT>
    	</TD>
            <TD vAlign=top bgColor=#ffffff>
            </TD>
       </TR>
    </TABLE>
    </p>
    

    Has anyone experienced anything like this? Any suggestions for a solution?
      Give a man the answer, and he’ll only have a temporary solution. Teach him the principles that led you to that answer, and he will be able to create his own solutions in the future.
      • 32699 ☆ A M B ☆
      • 427 Posts
      What code are you using for the state and provinces?
        Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

        Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
        • 38666
        • 98 Posts
        Quote from: wshawn at Mar 17, 2015, 10:15 AM
        What code are you using for the state and provinces?
        Two letter ISO codes, if that is what you mean otherwise the snippet and chunk above.
          Give a man the answer, and he’ll only have a temporary solution. Teach him the principles that led you to that answer, and he will be able to create his own solutions in the future.
          • 32699 ☆ A M B ☆
          • 427 Posts
          I assume you have a table assigned to
          $data = $modx->getObject('userData', array('userdata_id' => $userId));

          If you were intending to access the user profiles is would be:
          $data = $modx->getObject('modUserProfile', array('userdata_id' => $userId));
          


          In any case, here is a suggestion which should get you to an answer faster:

          $criteria = $this->modx->newQuery('modUserProfile'); 
          $criteria->where(array(
               $field => $value
          ));
                  
          $collection = $this->modx->getCollection('modUserProfile', $criteria);
          


          This allows you to do things like retrieving the actual SQL used in the query and use specified data pairs:

          $criteria = $this->modx->newQuery('modUserProfile'); 
          $criteria->where(array(
               // $field => $value
              'state'=>$csaacProv
          ));
              
          $criteria->prepare();
          echo $criteria->toSql();
             
          //$collection = $this->modx->getCollection('modUserProfile', $criteria);
          


          This could be as simple as the query needs to be:

          $criteria = $this->modx->newQuery('modUserProfile'); 
          $criteria->where(array(
               // $field => $value
               'state:LIKE' => '%"' . $csaacProv . '"%'
          ));
          


          Make sure your query is lining up to the table fields.

          I recently created a GeoGraphicalLookup platform for MODX Revo and had to develop a means to retrieve a Location by a half a dozen fields simultaneously.

          The table had to be defined so it was CI (case insensitive) in my case to make sure preexisting records of FL, Fl, fl where all matched.

          New users to sites are asked to select their State/ Province from the same table they are being retrieved from in situations such as yours.

          As far as the browser consideration is, other than a minimum length of page content for Internet Explorer there would be no reason for the query to work one way and not another.

          Is the snippet being ran cached?

            Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

            Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
            • 38666
            • 98 Posts
            Well, after three frustrating days and help from Shawn and others I have solved the mystery I'm embarrassed to say. Some one who shall remain unnamed but with the initials JS for got to publish the resource. That said, why did Firefox render the resource as published?
              Give a man the answer, and he’ll only have a temporary solution. Teach him the principles that led you to that answer, and he will be able to create his own solutions in the future.