We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14050
    • 788 Posts
    Here is a tpl file for anyone wishing to use weather.com. This is very basic, but using the template builder, this will easily get you started. An example can be seen here:


    http://www.cmssandbox.com/MODx095/index.php?id=57

    The snippet call is as follows:
    [!FeedX? &url=`http://xoap.weather.com/weather/local/YOURZIPCODE|xq|cc|xe|*|xa|prod|xe|xoap|xa|par|xe|YOURPARTNER#|xa|key|xe|YOURLICENSEKEY` &preset=`weather.com`!]


    Upload the attached zip into assets/snippets/FeedX/tpl/weather.com
      Jesse R.
      Consider trying something new and extraordinary.
      Illinois Wine

      Have you considered donating to MODx lately?
      Donate now. Every contribution helps.
      • 1932
      • 137 Posts
      @jester444:

      Thanks for the weather.com template. grin

      I haven’t done much in the way of calendar display - it looks like you would have to use another snippet to register new events (although you could access the feedx class directly to gain access to the parsed data). You might also look at using a Javascript-based calendar, using a custom FeedX template to write the necessary JS code.



      I’ve added a new feature to FeedX, &filterElements, which allows for the optional filtering of results. I’m currently using it to separate out different genres in my Last.fm music feed. This could also be useful for various things such as filtering of events, filtering of a feed by author, exclusion of advertisements/irrelevant content, censorship, etc. lipsrsealed

      $params['filterElements'] = isset($filterElements) ? $filterElements : '';
      	// Specify a field to perform a match on, where the matching value is a Perl-style regular expression
      	// Matching elements can either be excluded using EQ (equals) or included NE (not equals) operators
      	// Syntax: ELEMENT_NAME(FIELDNAME NE /value/)
      	//         Multiple elements can be defined and must be separated by a colon
      	// Example: `ITEM(TITLE EQ /advertisement|sponsor|partner/)`
      


      Using ’EQ’ will filter out results which do not match where as ’NE’ will only display matching results.

      Currently, matches are done using Perl-style regular expressions. An expression requires a start and end pattern delimiter (such as / and /). The pipe operator allows for the matching of multiple items (/this|that/ is equivalent to matching a string containing either this or that). A non case-sensitive match can be performed by using the i modifier, example:

      ITEM(TITLE NE /matched string/i)

      More information on regular expression syntax and modifiers can be found at the below URLs:

      http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
      http://www.php.net/manual/en/reference.pcre.pattern.syntax.php

      As usual, the new release can be downloaded from the first post of this thread. I plan to make an official release in the near future.
        • 4971
        • 964 Posts
        I was starting to play with "WeatherX" and jesster444 pointed me towards "FeedX" which I like a lot
        for the ease of implementation... thanks AppoXX... great snippet!

        My problem is with the tpl’s/chunks... all my templates are loaded perfectly as I can see in the debugger
        (another great addition!) but only the first chunk gets rendered in the web page, it does not go to the
        next ones.

        This is the HTML I want to produce... (please ignore the dot and node names, its so I don’t get confused, they are removed on the chunks...)

        <div class='weatherwrapper'>
        	<ul id='weatherloc'>
        		<li id='locid'>Cuernavaca</li>
        		<li id='latlon'>LAT [+loc.LAT+] - LON [+loc.LON+]</li>
        		<li id='elev'>ELEVACIÓN - 1560 m</li>
        		<li id='loctm'>(Datos de las [+loc.TM+])</li>
        	</ul>
        	<dl id='tempinfo'>
        		<dt id'temp'>[+cc.TMP+] °C</dt>
        		<dd id='ic_cli'><img src="http://image.weather.com/web/common/wxicons/52/[+cc.ICON+].gif" /></dd>
        		<dd id='feellk'>Se siente como</dd>
        		<dd id='flik'>[+cc.FLIK+] °C</dd>
        	</dl>
        	<ul id='weatherinfo'>
        		<li id='wcond'>[+cc.T+]</li>
        		<li id='hum'>Humedad: [+cc.HMID+]%</li>
        		<li id='dew'>Temp de Rocío: [+cc.DEWP+] °C%</li>
        		<li id='vis'>Visibilidad: [+cc.VIS+] Kms</li>
        		<li id='uv'>Indice UV: [+uv.I+]/16 [+uv.T+]</li>
        		<li id='wind'>Viento: Del [+wind.T+] a [+wind.S+] Km/H</li>
        		<li id='press'>Presión: [+bar.R+] hPa [+bar.C+]</li>
        	</ul>
        	<ul id='weathertiming'>
        		<li id='sunr'>Sale el Sol: [+loc.SUNR+]</li>
        		<li id='suns'>Mete el Sol: [+loc.SUNS+]</li>
        		<li id='daylf'>Luz Restante: [+loc.SUNS+] - [+loc.TM+]</li>
        	</ul>
        	<dl id='mooninfo'>
        		<dt id'luna'>LUNA</dt>
        		<dd id='moonph'>[+moon.T+]</dd>
        		<dd id='ic_moon'><img src="http://image.weather.com/web/common/wxicons/52/[+cc.ICON+].gif" /></dd>
        	</dl>
        </div> <!-- end of weatherwrapper -->
        


        and this is my "chunkanization" of the above...

        outer
        {{WEATHER->inner}}
        
        inner
        {{LOC->loc}}
        
        
        loc
        <div class='weatherwrapper'>
        	<ul id='weatherloc'>
        		<li id='locid'>Cuernavaca</li>
        		<li id='latlon'>LAT [+LAT+] - LON [+LON+]</li>
        		<li id='elev'>ELEVACIÓN - 1560 m</li>
        		<li id='loctm'>(Datos de las [+TM+])</li>
        	</ul>
        	{{CC->cc}}
        	<ul id='weathertiming'>
        		<li id='sunr'>Sale el Sol: [+SUNR+]</li>
        		<li id='suns'>Mete el Sol: [+SUNS+]</li>
        		<li id='daylf'>Luz Restante: [+SUNS+] - [+TM+]</li>
        	</ul>
        	{{MOON->moon}}
        
        uv
        		<li id='uv'>Indice UV: [+I+]/16 [+T+]</li>
        
        wind
        		<li id='wind'>Viento: Del [+T+] a [+S+] Km/H</li>
        
        bar
        		<li id='press'>Presión: [+R+] hPa [+C+]</li>
        
        cc
        	<dl id='tempinfo'>
        		<dt id'temp'>[+TMP+] °C</dt>
        		<dd id='ic_cli'><img src="http://image.weather.com/web/common/wxicons/52/[+ICON+].gif" /></dd>
        		<dd id='feellk'>Se siente como</dd>
        		<dd id='flik'>[+FLIK+] °C</dd>
        	</dl>
        	<ul id='weatherinfo'>
        		<li id='wcond'>[+T+]</li>
        		<li id='hum'>Humedad: [+HMID+]%</li>
        		<li id='dew'>Temp de Rocío: [+DEWP+] °C%</li>
        		<li id='vis'>Visibilidad: [+VIS+] Kms</li>
        		{{UV->uv}}
        		{{WIND->wind}}
        		{{BAR->bar}}
        	</ul>
        
        moon
        	<dl id='mooninfo'>
        		<dt id'luna'>LUNA</dt>
        		<dd id='moonph'>[+T+]</dd>
        		<dd id='ic_moon'><img src="http://image.weather.com/web/common/wxicons/52/[+ICON+].gif" /></dd>
        	</dl>
        </div> <!-- end of weatherwrapper -->
        


        as I mentioned, all of them are loaded perfectly but it only goes to the loc chunk,
        it never goes to cc or to moon??? I must be doing something really stupid that I do not see...

        do I have to create does as chunks instead of templates? I don’t think so my previous attempt with
        smaller chunks worked fine using templates...

        appreciate the help!
          Website: www.mercologia.com
          MODX Revo Tutorials:  www.modxperience.com

          MODX Professional Partner
          • 14050
          • 788 Posts
          The problem you have is from calling things in the wrong order :-D

          HEAD, LOC, and CC are children of WEATHER. As such, you can only reach those by calling them inside your "inner" chunk. LOC has no children, and as such you can’t reference MOON or CC inside of it. You need to reference CC->cc in your "inner" chunk" and then inside CC you can reference any of its children, which are BAR, WIND, UV, or MOON.

          So this is probably what your chunks should look like:

          outer
          {{WEATHER->inner}}


          inner
          {{LOC->loc}}
          {{CC->cc}}
          

          loc
          <div class='weatherwrapper'>
          	<ul id='weatherloc'>
          		<li id='locid'>Cuernavaca</li>
          		<li id='latlon'>LAT [+LAT+] - LON [+LON+]</li>
          		<li id='elev'>ELEVACIÓN - 1560 m</li>
          		<li id='loctm'>(Datos de las [+TM+])</li>
          	</ul>


          cc
          <dl id='tempinfo'>
          		<dt id'temp'>[+TMP+] °C</dt>
          		<dd id='ic_cli'><img src="http://image.weather.com/web/common/wxicons/52/[+ICON+].gif" /></dd>
          		<dd id='feellk'>Se siente como</dd>
          		<dd id='flik'>[+FLIK+] °C</dd>
          	</dl>
          	<ul id='weatherinfo'>
          		<li id='wcond'>[+T+]</li>
          		<li id='hum'>Humedad: [+HMID+]%</li>
          		<li id='dew'>Temp de Rocío: [+DEWP+] °C%</li>
          		<li id='vis'>Visibilidad: [+VIS+] Kms</li>
          		{{UV->uv}}
          		{{WIND->wind}}
          		{{BAR->bar}}
          	</ul>
          {{MOON->moon}}
          

          uv
          <li id='uv'>Indice UV: [+I+]/16 [+T+]</li>


          wind
          <li id='wind'>Viento: Del [+T+] a [+S+] Km/H</li>


          bar
          <li id='press'>Presión: [+R+] hPa [+C+]</li>


          moon
          	<dl id='mooninfo'>
          		<dt id'luna'>LUNA</dt>
          		<dd id='moonph'>[+T+]</dd>
          		<dd id='ic_moon'><img src="http://image.weather.com/web/common/wxicons/52/[+ICON+].gif" /></dd>
          	</dl>
          </div> <!-- end of weatherwrapper -->


          That should work. Although I did that quickly. You can only move from Parent->Child and not from Child->Child or Cousin->Cousin or Child->Parent from my understanding.
            Jesse R.
            Consider trying something new and extraordinary.
            Illinois Wine

            Have you considered donating to MODx lately?
            Donate now. Every contribution helps.
            • 4971
            • 964 Posts
            Thanks again Jesse, I understand now...
            if I need to use children in two separate places... I just produce loc and loc1??
            {{LOC->loc}} and {{LOC->loc1}} ??
              Website: www.mercologia.com
              MODX Revo Tutorials:  www.modxperience.com

              MODX Professional Partner
              • 1932
              • 137 Posts
              @charliez, glad you like the snippet grin
              Yes, you can display children in multiple places by re-using elements just like your example.
                • 4971
                • 964 Posts
                Thanks a million Jesse and ApoXX...
                it works like a charm, now that I undesrtand it fully...
                now some CSS and I will be done... thanks again!
                  Website: www.mercologia.com
                  MODX Revo Tutorials:  www.modxperience.com

                  MODX Professional Partner
                  • 4971
                  • 964 Posts
                  Is there a way to process the info coming from the snippet in placeholders?

                  I am using this:

                  <div class='weatherwrapper'>
                  	<ul id='weatherloc'>
                  		<li id='locid'>[+dnam+]</li>
                  		<li id='latlon'>LAT [+LAT+] - LON [+LON+]</li>
                  		<li id='elev'>ELEVACION - 1560 m</li>
                  		<li id='loctm'>(Datos de las [+TM+])</li>
                  	</ul>
                  


                  in a template in a weather.com feed and is working fine. The dnam placeholder gives me
                  "city, state". I would like to parse the placeholder so to display the city only.

                  I tried the following:

                  <div class='weatherwrapper'>
                  	<ul id='weatherloc'>
                  		<li id='locid'><? $dnam='[+dnam+]';$locn=explode(',',$dnam);echo $locn[0]; ?></li>
                  		<li id='latlon'>LAT [+LAT+] - LON [+LON+]</li>
                  		<li id='elev'>ELEVACION - 1560 m</li>
                  		<li id='loctm'>(Datos de las [+TM+])</li>
                  	</ul>
                  


                  but it does not work. The snippet places a $value in $name and then forms the placeholder,
                  so it has to be possible to extract it and process. Any pointers?
                  Thanks in advance...
                    Website: www.mercologia.com
                    MODX Revo Tutorials:  www.modxperience.com

                    MODX Professional Partner
                    • 1932
                    • 137 Posts
                    Yes, take a look at PHx. Specifically custom modifiers.

                    Snippet: phx:splitloc
                    <?php
                      $locn = explode(', ', $output);
                      return $locn[0];
                    ?>
                    


                    Template code:
                    <li id='locid'>[+dnam:splitloc+]</li>
                    
                      • 4971
                      • 964 Posts
                      Yes, thanks again... MODx keeps amazing me... this PHx is very nice,
                      it solve my problems.
                        Website: www.mercologia.com
                        MODX Revo Tutorials:  www.modxperience.com

                        MODX Professional Partner