We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

json data module | Help [SOLVED]

Development and Programming

thisconnect.be's avatar
thisconnect.be
73 posts
18 years ago
thisconnect.be's avatar thisconnect.be

Hello all,

I have created an extension that allows you to select a weblog and category in a custom field. Now when a weblog is selected a json calls happens to the module this module should then return json data.

The url that i use to call my json is : http://localhost/ExpressionEngine1.6.0/system/index.php?S=43f0f0e01c033490c776695527aced2a65edd702&C=modules&M=Select_blog&P=ajax_categories_search The problem is that this also displays the menu and header etc… all the things i dont need.

I tryed clearing $DSP=”” which works but gives me an error: Fatal error: Call to a member function show_full_control_panel() on a non-object in /Users/kevin/webroot/ExpressionEngine1.6.0/system/core/core.system.php on line 883

So my question is how to handle is there a function to prevent any output?

Here you can see my code if that helps clearifying things. Thanks for any help!

<?php
class Select_blog_CP {

 var $version = '1.0';
 
 // -------------------------
 // Constructor
 // -------------------------
 
 function Select_blog_CP($switch = TRUE)
 {
  global $IN, $DB;
  
  // Is Module installed?
  if ($IN->GBL('M') == 'INST')
  {
   return;
  }
  
  // Check installed version
  $query = $DB->query("SELECT module_version FROM exp_modules WHERE module_name = 'Select_blog'");
  
  if ($query->num_rows == 0)
  {
   return;
  }
  
  // update version number
  if ($query->row['module_version'] < $this->version)
  {
   $DB->query("UPDATE exp_modules SET module_version = '{$this->version}' WHERE module_name = 'Select_blog'");
  }
  // end update
  
  
  if ($switch)
  {
   switch($IN->GBL('P'))
   {
    case 'ajax_categories_search' : $this->ajax_categories_search();
     break;
    default: $this->ajax_categories_search();
     break;
   }
  }
 }
 // END
 
 // ----------------------------------------
 // Ajax Entry Search
 // ----------------------------------------
 
 function ajax_categories_search()
 {
  global $DSP;
 //$DSP ="";
  echo '{"previews":[
 {"name":"Blue Earth", "src":"earth-blue.jpg", "description":"A blue version of Earth.", "views":200},
 {"name":"User Profile", "src":"user.jpg", "description":"A chubby user guy.", "views":0},
 {"name":"Mouse", "src":"mouse.jpg", "description":"Standard mouse icon.", "views":99},
 {"name":"Gold Earth", "src":"earth-gold.jpg", "description":"A gold version of Earth.", "views":7855},
 {"name":"Page and Pencil", "src":"edit.jpg", "description":"A piece of paper and a pencil.", "views":5},
 {"name":"Speaker", "src":"speaker.jpg", "description":"A speaker.", "views":16},
 {"name":"Orange Monitor", "src":"monitor.jpg", "description":"A yellow, glowing monitor.", "views":355},
 {"name":"Software Box", "src":"package.jpg", "description":"A nice wrapped package in a box.", "views":23452},
 {"name":"FIRE!!!!", "src":"fire.jpg", "description":"Orange flame.", "views":395},
 {"name":"Screwdriver Paper", "src":"setting.jpg", "description":"A screwdriver in front of a piece of paper.", "views":42}
]}';
  $DSP = "";
  /**
  global $DB, $DSP, $REGX, $IN, $PREFS, $LANG, $LOC, $SESS;
  
  $weblog_name = ($IN->GBL('weblog', 'POST') !== FALSE) ? $REGX->keyword_clean($IN->GBL('weblog', 'POST')) : '';
  
  if ($PREFS->ini('auto_convert_high_ascii') == 'y') {
   $keywords = $REGX->ascii_to_entities($keywords);
  }
  $sql =" select cat_group from exp_weblogs where blog_name='".$weblog_name."'";
  $res = $DB->query($sql);
  foreach ($res->result as $r){
   
  }
  return '{"previews": [{"name":"test"}]}';
  //if ($keywords == '') exit('<div class="highlight">'.$LANG->line('msg_no_results').'</div>');
  */
 }
 // END
}
       
thisconnect.be's avatar
thisconnect.be
73 posts
18 years ago
thisconnect.be's avatar thisconnect.be

Oke nvm my post from above i found a workarround thanks to cocoaholic (again :p).

We are now using the mod page instead of the mcp page. The problem with the mcp page is that it always sends a header along that i cannot seem to be able to remove. So now i just call the json result page as followed: “http://localhost/ExpressionEngine1.6.0/index.php?ACT=23” Where 23 is the id of the action in the exp_actions table.

Grtz,

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.