Jump to content

howster2011

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

howster2011's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Fantastic meltingpoint. I really appreciate your time and effort on this one. Finally the solutions can be seen here http://forums.modx.com/thread/72373/output-modifier-snippet---php-modx-guru-needed-for-this-one#dis-post-402750 Modx has special syntax for calling the id into a snippet it appears, namely: $resource = $modx->resource->get('id'); instead of: $resource = '[[*id]]'; THANKS
  2. Will look at it again in the morning. Getting late here in Ireland. THANKS A MILLION for all your time and help meltingpoint. I think modx has a setting that makes this nigh impossible. Will start a thread on their forum tomorrow. Thanks
  3. Its modx i.e. www.modx.com and the id would look like mydomain.com/index.php?id=18 if furls are off. The specific "Resource ID" is the number of digits in a number i.e 100 is 3 digits, 50 is 2 and so on A string of 7 shouldnt come into play only thats its weird [[*id]] has 7 digits/characters
  4. Its a modx system tag - the only light I can shed on it is: http://rtfm.modx.com/display/revolution20/Commonly+Used+Template+Tags - hopefully this helps
  5. Unfortunately it still shows eg string(7) "3" and there are 7 characters in [[*id]] - should I perhaps wrap [[*id]] in something other that single or double quotes?
  6. ok thanks - I get string(7) "3" and string(7) "54" for the pages causing the issues and these ids are completely correct. The [[ syntax must be confusing things. Perhaps they should be wrapped in something other than ' or ". Any conditional with || is basically getting screwed up.
  7. Hi, How would you integrate var_dump please? I think the issue is with $id holding the value of [[*id]] correctly. I am basing the expressions off this code (and yours) which works fine <?php $RandomNumber = rand(1, 4); if ($RandomNumber == '1') { // PHP If Statement echo 'The number was 1'; } elseif ($RandomNumber == '2') { // PHP Elseif Statement echo 'The number was 2'; } elseif ($RandomNumber == '3') { // PHP Elseif Statement echo 'The number was 3'; } else { echo 'The number was 4'; // PHP Else } ?> var_dump may work if you wouldnt mind showing me how to integrate it. Ultimarely I need this code below to work where i call html code based on page id <?php $resource = '[[*id]]'; if ($resource == '3' || $resource == '24' || $resource == '35' || $resource == '38' || $resource == '42' || $resource == '44' || $resource == '47' || $resource == '32'){ echo "[[!include? &file==`assets/templates/inc/newslisting.php]]"; <--this displays [[!include?&file==`assets/templates/inc/textContent.php]] incorrectly } else if ($resource == '54' || $resource == '64' || $resource == '75'){ echo "[[!include?&file==`assets/templates/inc/bloglisting.php]]"; <-- this displays blank i.e. echo fails } else if ($resource == '56'){ echo "[[!include?&file==`assets/templates/inc/contact.php]]"; <-- this display correctly } else{ echo "[[!include?&file==`assets/templates/inc/textContent.php]]"; <-- this displays correctly } ?> I said I'd query the concept in more basic terms above before tackling this specific code hence different names. The [[include...]] part evaluates to a chunk of html Thanks
  8. Thanks meltingpoint - I looked at switch but i need to incorporate ORs via if elseif else statements - its just way handier if I can get it to work. I assume I can use multiple elseif's if elseif elseif else Maybe there is some caching of the $id value going on or I have to wrap the $id in some other syntax. Hmmm
  9. spoke to soon xor appears to work for ($id="1" xor $id="2") i.e comparing 2 ids. If I want to compare 3 or 4 eg ($id="11" xor $id="12" xor $id="13" xor $id="14") it breaks again. So back to || it seems or some other OR type operator
  10. stumbled across a solution. Using xor instead of || seems to work. Thanks
  11. if eg I am in page with id 3 the code evaluates as "we are in 1 or 2" as opposed to "we are in 3 or 4" If i am in page with id 1 the code evaluates "correctly" as "we are in 1 or 2"
  12. I tested using $id='[[*id]]'; - sorry missing ; - Still doesnt work unfortunately
  13. Hi there, When I echo $id specifically it returns the correct value i.e. the page id. Thats tried and tested. The issue seems to be the syntax of the OR operators. I tried numerous variants of using =,==," and ' Thanks
  14. Hi Guys, Newbie trying to understand PHP conditionals. In the below [[*id]] is a global variable which equates to my current page id so it could have the value of 1 for example. I tested it using echo and the correct values pass to it in the cms I'm using. What I cant achieve is for the conditionals below to work correctly so perhaps you can see a syntax error or show me away of doing the same using an array or something perhaps? THANKS <?php $id='[[*id]]' if ($id=="1" || $id=="2") echo "we are in 1 or 2"; elseif ($id=="3" || $id=="4") echo "we are in 3 or 4"; else echo "not in 1 to 4"; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.