Hot answers tagged

18

Hooks are rather abstract and require you to have a working plugin/module with your own hooks setup. So before you go any further I would be sure you have a good grasp on how to use the most basic forms of hooks. It might be wise to even write a simple extension just to go through the process. Postmaster extends ExpressionEngine's native handling of hooks. ...


12

You should be able to implement redirects once you add the Stash no_results_prefix parameter. For example: //Collect all values for all custom fields {exp:stash:set parse_tags="yes" trim="yes" parse_conditionals="yes" no_results_prefix="equipment"} {exp:channel:entries channel="equipment" url_title="{segment_3}" require_entry="yes"} {if equipment:...


12

This is not natively supported in ExpressionEngine. The "official" was to do something similar to this would be to simply use additional module tags. Is there a reason you would not want to do that? {exp:mod:method} <h1>{top_level_var}</h1> {exp:mod:var_pair limit="7" number="42"} <p>{var_pair_variable}</p> {/exp:...


10

If you're looking to stick with CodeIgniter's pattern for OOP (which is very standard) you would have your data methods in one or more models, your view files (for a control panel interface) in a views directory and your two module files (mcp.* and mod.*) would act as your two controllers. As such, your directory structure might look something like this: /...


9

Your biggest point of attention should be the response header for your URL. EE will take care of setting it as a 404 response provided you have selected the template in use in the Global Template Preferences seen below. (Docs reference) I'd recommend using a template rather than an entry + pages module. It's just simpler that way.


9

Ok, this is something it looks like Ellis is not ready to really let people do even though it's in documentation, except perhaps developers who would provide via a full add-on installer and handling. However, it is possible. a. First, there is an EE interface to install new button features, but it is not called anywhere, Addons_installer:install_rte_tool. ...


8

I've done this by securing the ACT id with a token of sorts, then before calling the API to import the data - I simply create a temporary user session for a superadmin. Example: function login_temporary_user() { if( $this->EE->session->userdata['member_id'] == 0) { $this->EE->session->create_new_session(1, TRUE); $...


8

The ‘p’ in your module’s class name must be lowercased. From http://ellislab.com/expressionengine/user-guide/development/modules.html#the-core-module-file-mod-module-name-php: The Core Module file is used for outputting content via Templates and doing any processing that is required by both the Control Panel and any module tags contained in a template. ...


7

Most serious modules I know of create their own settings table. It's not ideal, but EE doesn't really offer any built in solutions for modules. If your module has an extension, as Tom mentioned, you can use that to store a serialized array of settings. Alternatively, I know some modules add a settings column to the exp_modules table (obviously after ...


6

I worked through this with Justin and wanted to post this so others can use it. Basically I have a mod file with a custom function that logs when an image is downloaded. My variables are all logged after being set up. Here's the variables: $my_download = array(); $my_download["size"] = $image_size; $my_download["entry_id"] = $entry_id; $...


6

There are no existing extensions that I'm aware of that can handle this functionality. Currently promo code discounts are applied to a whole order, not individual items. However, it would certainly be possible to write something in PHP to handle this using the extension hooks.


6

On a single entry page (ie one with a url_title or entry_id in the URL) you can use the require_entry="yes" parameter, by using this in conjunction with the {if no_results} conditional, to only show a "proper" page when a valid entry is passed. {exp:channel:entries require_entry="yes"} {if no_results} {redirect="site/404"} {/if} <h2>{title}&...


6

$mod_data['module_name'] should be class name of your actual module file (mod.photo_pdf.php), in your case 'Photo_pdf'


6

When you pass an array of data on to a view file, the keys become the variable names in that view file. So... $data = array( 'foo' => 'bar', 'lorem' => 'ipsum' ); return $this->EE->load->view('my_file', $data, TRUE); ...will mean that in the my_file view file you can then use the variables $foo and $lorem. In your case, that would ...


6

I think you're looking for this page in the EE Developer docs. Basically, if you only need the JS in the Control Panel (so not on the front-end of the site), put your JS files in the /your_addon_package/javascript/ folder and then use $this->EE->cp->load_package_js('my_file'); to load it. If you need the JS outside of the CP as well, you need to ...


6

This is a bit of an undocumented feature, but it works like this. In your extension, add a class variable called $required_by, with an array of values: $required_by = array('module'); ('module' is actually the only acceptable array value here, as neither plugins nor accessories have installation routines, which are needed for this to work.) Note that ...


5

The parse_variables function handles this natively so there's really no need to complicate things unless you need some additional functionality. The template class documentation includes some detailed instructions, but basically you just need to add a my_fields array to your main array of variable data. $vars['title'] = 'My Title'; $vars['my_fields'] = ...


5

If secure forms is set to no in security settings, EE's forms don't use XID. Whilst this doesn't solve the problem of the data not saving, it should explain why there is no XID...


5

To get a single value, you want to use the row() method on your $query object: $this->EE->db->select('my_col'); $query = $this->EE->db->get_where( 'fb_photo_settings', array('setting_name' => 'facebook_id') ); $var = $query->row('my_col'); To get an object with a whole row: $query = $this->EE->db->get_where( '...


5

The methods you want to use in order to have a tag pair is: //To loop over multiple items with variables //inside each (eg: looping through entries $this->EE->TMPL->parse_variables($template, $data); //To show a single item with multiple variables within it $this->EE->TMPL->parse_variables_row($template, $data); Most of the time you ...


5

EE's contact form does not support custom fields per se (i.e., it doesn't support the custom fields you'd use for your channels), but you can have multiple fields populate the message by naming each with an array syntax: <label for="message">Your Message</label> <textarea name="message[]" id="message"></textarea> <label for="how"&...


5

Solspace's Freeform has a dynamic recipients functionality that just might serve your needs. I quote: recipients="yes" This parameter allows you to let your users select recipient email addresses dynamically within the form itself. So for example, you can have a dropdown select menu that allows your users to select the destination for their email (...


5

You can use $this->EE->output->send_ajax_response($array); for the same purpose.


5

Good on you for writing your first plugin. Use this as a starting point for your plugins, quick, easy and avoids missing something. pkg.io Create it, download, unzip and upload to third party folder, just like any other add on. Once you can 'see' it in the plugin/module list you're all set to add your code.


5

First, no need to ever load directly from CI - you can always use EE. (So, $this->EE->load->helper('file').) Same with your validation class - I'd extend Form_validation, not CI_Form_validation. (Generally, EE should serve as your path to anything CI-related to avoid any conflicts.) You'll need to load your custom validation library, and call it ...


4

Generally if form submissions aren't working, your .htaccess file is to blame. Specifically, if you are using NSM htaccess generator, I've seen numerous problems with that, so avoid it. Also, if you are trying to force trailing slashes, stop now. EE 2.x really likes no trailing slash, and fighting it gets you nowhere. The best solution is always to use the ...


4

What's Going Wrong You've already spotted the problem but here's a quick explanation of why the error is occurring. If you enable pagination EE1's query module will issue two queries - one calculates the total number of results sans-pagination and the other issues the query itself with an additional LIMIT parameter. The total results query is generated by ...


4

Neither Active Record nor DB Forge have a “SHOW TABLES” function. You’d have to just do it with query(): if ($EE->db->query('SHOW TABLES LIKE `exp_mytable`')->num_rows())


4

Your example code shows you doing two things: Listing any existing comments on the entry ({exp:comment:entries}) Displaying a list of Channel Entries ({exp:channel:entries}) Nowhere are you displaying the comment form (even though you linked to the documentation on it). However, the comment form is generally meant to be used on a "single entry" template, ...


4

Yes via ACTion URLs, tutorial here. Basically in your install method (in your upd. file): //### Create ACTion IDs for the relevant functions ### $formActions = array( "YOUR-METHOD-NAME" ); foreach ($formActions as $method) { $data = array( 'class' => $this->class, 'method' => $method ...


Only top voted, non community-wiki answers of a minimum length are eligible