Jump to content

entheologist

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by entheologist

  1. I don't know what this is called, relationship relationship maybe. I have a drugs custom post type and an ailments custom post type. A drug can either remedy or cause an ailment, so I need to be able to add whether its a remedy or cause to the relationship table. I've been using pods for managing custom post types, is there a built in way to do this?
  2. Same here, wish I could find it. Need to start looking into how to find these things.
  3. This is one of the extremely rare cases where something I tried worked first time, but it did: trait optionSetterTrait { private $_diagnose = array(); public function __construct(array $options = array()) { $this->_diagnose['options'] = $options; // show numeric values of each setting $this->_diagnose['settingsKeys'] = array_keys($this->_settings); // array_intersect_key so only recognized $options get merged in $this->_settings = array_merge($this->_settings, array_intersect_key($options, $this->_settings)); $this->_diagnose['settings'] = $this->_settings; } public function __get($name) { return (isset($this->_settings[$name]) ? $this->_settings[$name] : null); } public function __set($name, $value) { if (isset($this->_settings[$name])) { $this->_settings[$name] = $value; } } public function diagnose() { if (empty($subSection) || $subSection == 'all') { } $outputArray = print_r($this->_diagnose,true); $output = "<pre>$outputArray</pre>"; echo $output; } } class linkFinder { private $_settings = array( 'paths' => array('./'), 'extenstions' => array('php','html'), 'category' => 'blah' ); use optionSetterTrait; private function linkGenerator() { $fileList['fullPath'] = glob("./*.php"); } } $test = new linkFinder(array('category' => 'blah')); $test->diagnose(); So from now on in every class I make I can just include that optionSetter trait, that will make life so much easier. Does anyone know of a trait like this been made before? If not I should put it up on github as a gist so people can improve it over time.
  4. Thanks a lot. I'll try out your method. I just found out there is an array_replace function, even an array_replace recursive function which would be perfect would replacing defaults with user input options. This will work perfect for when users input associative arrays, but won't account for numeric arrays. We need to make a universal options settter function/class/trait that will take care of all these possibilities.
  5. I've been wasting time reinventing the wheel with this one so I'd greatly appreciate if people here could share how they deal with this. So heres an example class: class VarDataClass { private $module = 'show_vars'; public $category = 'DEFAULT CATEGORY'; public $title = 'DEFAULT TITLE'; public $option2 = 'DEFAULT VALUE'; public $show = 'SOMETHING'; public $output = 'box'; public $_settings = array( 'category' => 'DEFAULT CATEGORY', 'title' => 'DEFAULT TITLE', 'option2' => 'DEFAULT VALUE', 'show' => 'SOMETHING', 'output' => 'box' ); public function __constructor($options = array()) { } // some functions } So the $options parameter in the constructor contains all the custom settings for the class instance, lets say in this case they're all optional. Since they're all optional I made that $_settings array have default values. And for this example, I added another way I could do it, by adding the variables individually rather than as part of the settings array. So I'm wondering whats the best way to replace the default values with any values that the user happens to input. Is a list of variables easier, or is the $_settings array the way to go? I think the settings array would be the way to do it, so I'm thinking I should make some option setter function, but whats the easiest way to do that? Should I loop through every key in the settings array, and check if that key is present in the $options variable that the user input? Or is there some kind of array_replace function I can use that will set all the options in one go without having to use a loop? Another issue is its a pain in the ass for the user to input an associative array, its much easier to just to $object = new VarDataClass('CATEGORY','TITLE'); etc. but then the problem is if they only want to set say the two last options, they'd have to do VarDataClass('','','','SHOW','OUTPUT'); Basically I'm just looking for the most evolved way to handle these optional functions so I don't have to reinvent the wheel myself.
  6. I want to install this package: https://github.com/composer/installers from GitHub, I can easily git clone it but I think its better I get experienced with composer. In the readme they onyl give one example, one involving CakePHP: { "name": "you/ftp", "type": "cakephp-plugin", "require": { "composer/installers": "~1.0" } } but I that isn't much help to me since I'm not making composer.json files to hold a single framework or plugin, my json files look more like this: { "name": "example-app", "require": { "cakephp/cakephp": ">=2.5.1", "cakephp/debug_kit": "2.2.*", "slywalker/boost_cake": "*", "CakeDC/tags": "1.*", "CakeDC/utils": "*", "CakeDC/migrations": "*", "FriendsOfCake/crud": "*", "CakeDC/search": "*", "paulredmond/chosen-cakephp": "*" }, "config": { "vendor-dir": "Vendor/" }, "extra": { "installer-paths": { "app/Plugin/Tags": ["CakeDC/tags"], "app/Plugin/BoostCake": ["slywalker/boost_cake"] } } } Right now I'm working on a WordPress one and it is 10 times longer than that. So what I was wondering is if its better to split it up into a few composer.json files. As in one file for setting up the framework and configuring it, when its done, it calls a second composer.json file that will take care of installing the plugins. Like this I suppose I could store a bunch of composer.json files in a central location, each of them has a specific purpose, so if I need to use one of them for a project, I just call composer.phar file (which I can access globally), and use that global keywork to make the json file operate like its in my projects directory. I don't understand what this autoload thing is about at all, but its nice the way it lets you run scripts at particular times during the execution of the json file. Is this actually a better way to work with composer, by chaining separate composer.json files together? A big issue is the name conflict thing, is there a way to make composer.phar process files with different names? It be a pain in the ass having to make the scripts alter the filenames. That gets me thinking about something. Can we define variables in composer.json files? If not, I suppose its not very hard to do it anyway by editing the file. I was thinking there that a composer file generator would be pretty useful. Like say on CakePHPs website, theres a page that lets you check plugins and features that you want for your new installation, then it makes a composer.json file for you.
  7. I decided to use wordpress to make the CRUD system to simplify things. I know how to do this relation thing, but I don't know if I'm doing it right. I made a single relational database which contains columns plant_id, compound_id, product_id etc. Would I be better off making a separate table for each relation, i.e, a plant_compound table, a plant_product table, a product_compound table. I think I just answered my own question there, that would be way less practical than just using one table.
  8. I like to set up websites for people who don't have the know how to do it themselves, I mainly set them up wordpress sites cuz thats pretty easy for them to modify and maintain themselves. To save myself time, I decided to learn how to do it with Composer (what a brilliant tool that it). Can anyone who uses composer for this kinda thing, can you post your composer.json files here. Also, if anyone can show me a better way of doing things, it'd be much appreciated. Heres the one I made: { "name": "acme/brilliant-wordpress-site", "description": "My brilliant WordPress site", "repositories":[ { "type":"composer", "url":"http://wpackagist.org" } ], "require": { "johnpbloch/wordpress": ">=3.8.0", "wpackagist-plugin/captcha":">=3.9", "wpackagist-plugin/tinymce-advanced":">=4.0.0", "wpackagist-plugin/wordpress-importer":"*", "wpackagist-theme/hueman":"*", "wpackagist-theme/eclipse":"*", "wpackagist-theme/raindrops":"*" }, "extra": { "installer-paths": { "mysite": ["johnpbloch/wordpress"], "mysite/wp-content/plugins/{$name}": ["type:wordpress-plugin"], "mysite/wp-content/themes/{$name}": ["type:wordpress-theme"] } }, "autoload": { "psr-0": { "Acme": "src/" } } } I think I'm doing this in a silly way though. I read about these composer installer things on github, but I didn't figure out how to use them so instead I used the installer-paths key to make the autoloader put the files in the right place. Heres a composer.json file I found which is better cuz it uses a post installation script: { "require": { "wordpress/core": "3.5.2", "wordpress/twentytwelve": "1.1", "wordpress/akismet": "2.5.7", "wordpress/google-sitemap-generator": "3.2.9", "wordpress/google-analytics-for-wordpress": "4.3.3", "wordpress/wordpress-importer": "0.6.1" }, "repositories": [ { "type": "composer", "url": "https://raw.github.com/wordpressoncomposer/composer-repository/master/" }, { "type": "vcs", "url": "https://github.com/wordpressoncomposer/installer" } ], "scripts": { "post-install-cmd": "Wordpress\\Composer\\InstallerTasks::wpConfig" }, "extra": { "wordpress_coredir": "wordpress/core", "wordpress_wp_contentdir": "wordpress/wp-content", "wordpress_wp_config": { "site_url": "http://localhost", "db_host": "localhost", "db_user": "root", "db_pass": "", "db_name": "wordpress" } }, "minimum-stability": "dev" } I'm gonna start using these scripts once I figure out how to use them. Where are the scripts stored? I haven't a clue what this autoload thing is all about either, is it a tool for moving files into the appropriate directories? See how the first file gets wordpress from packagist, and the second one gets it from github. Is there a difference? If I was to add that post-install-cmd key to the first composer.json file, would it still work? In other words, do both repositories contain identical packages.
  9. Barand: Yeah each plant contains multiple compounds. A compound can be found in multiple plants. A product can contain multiple plants or compounds. An illness can be treated with multiple substances. I setup a relational table that takes care of this, the table has a column for plant_id, compound_id, product_id, illness_id. CakePHP isn't really compatible with composite keys like that though. I had this relational system up and running in a wordpress plugin, but there were so many glitches I abandoned that and switched to CakePHP.
  10. The issue there is on say the pain page, I'll need to list Compounds: morphine, Plant remedies: opium poppy, Medications: Morphine XR Every table has multiple relations to each other table.
  11. I have a database table of plants, one of chemicals, one of products, one of illnesses. Each table is connected, for example lets say opium poppies. They contain the chemical morphine. Morphine is used in painkiller products. Its used to treat pain and other illnesses. On the opium poppy page, I want to list all the chemicals found in the poppy. All the products (i.e. opium, laudanum) made from the poppy. All the illnesses which are treated with the poppy. Users need to be able to edit this page, and enter chemicals, products or illnesses that are related to this plant. They also need to be able to edit the info on the page. Making database relations is a pain in the ass with CakePHP. I don't want to waste any more time so I'm thinking maybe making it as a wordpress plugin is the way to go. How would you go about this? Is there an easier way than wordpress, like a better CMS, or framework? If I use wordpress, should I do all the DB interactions with AJAX to avoid having to interact with the DB through wordpress (this gave me massive trouble in the past since I had my data in an external db)?
×
×
  • 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.