The only condition is that you have to modify your ‘mod.weblog.php’ file to allow the extension hook. You can find instructions for that in the top of the .php file.
Hi. I’m trying to get this extension to work. I’m encountering the same problem that Rob Q was encountering, and I’m 99% certain the reason is that I haven’t modified the mod.weblog.php file. But I can’t for the life of me find the instructions for doing that in the top of the .php file.
If you open the extension in an HTML editor it has this instruction for modifying the mod.weblog.php file which itself is found in System > Modules > mod.weblog.php.
So in mod.weblog.php search for
($this->paginate == TRUE)
—I believe there is more than one instance but it should be around line 2137
FIND THIS: // ---------------------------------------- // Do we need pagination? // ---------------------------------------- // We'll run the query to find out if ($this->paginate == TRUE)
INSERT THIS RIGHT BEFORE THAT LINE: // ------------------------------------------- // 'build_sql_query' hook. // - Rewrite, or add to the sql query // global $EXT; if (isset($EXT->extensions['build_sql_query'])) { $sql = $EXT->call_extension('build_sql_query', $sql, $this); if ($EXT->end_script === TRUE) return; } // // -------------------------------------------
Can I have two conditions (notice the last two conditions: efront and esloc), but then look closer at esloc - I tried to include two different settings. Is this possible? If not I would love to add this as a feature request.
Mark, Thanks so much for taking up the Extensions challenge and bringing us functionality we long for such as in this extension. Count me as another grateful user of your work.
Can I have two conditions (notice the last two conditions: efront and esloc), but then look closer at esloc - I tried to include two different settings. Is this possible? If not I would love to add this as a feature request.
ok try the latest version, it should work with multiple conditions, however it will combine them with an AND so you will get entries with efront=“yes” AND esloc=“delaware|virginia”. of course if you wanted to do delaware OR virginia you could use a “sql” attribute like so, to basically create a custom query
And of course Genre is my custom field where authors can select from Metal to Classic.
If this is not working with your extension I have two questions:
- What can be done to make it work?
- If there’s nothing that can be done about it, am I correct that the only way to program this is to have a huge list of conditional variable where I have to code each “genre” as a seperate possible query?
- Or is there a clever MySQL query that could help me out?
job_application_deadline is the custom field. Right now I’m checking to see if it is ‘3’ - it’s a timestamp field so that shouldn’t return any results, but they all show. I’ve messed around with parameter order, as well as removing all the other parameters and still no go.
Any ideas?
EDIT: I’m an idiot. I hadn’t enabled the extension - it’s working great.
Thanks again Mark for your tireless efforts to extend EE!
This extension doesn’t seem to work if you’re selecting a random entry. What I would like to happen is select a random entry from those with a certain field filled - so it only chooses from the entries with information in that field.
Is it possible to match a partial pattern? For example, could you get it to display entries where the specific custom field is 2.1, 2.1.1, 2.1.2 and 2.1.2.1 by matching on 2.1*? Or could the greater than option handle that sort of progression too?
The Pie Man, it won’t work when selecting a random entry because EE picks the random entry before my code executes. I’m not too sure what can be done about this. In your specific case it may be easier to just use a full-blown {exp:query sql=”“} tag.
Linda, it should work, however, you would want to use the SQL syntax like so: field_name=’2.1%’. I believe that would do it.
Should it still work if it needs to fetch the number from a segment? I tried ‘{exp:weblog:entries weblog=”{current_weblog}” 32_number_display=”{segment_3}%”}’ and that doesn’t seem to work.
Edited to add: Tested by adding the number straight in there too, but that doesn’t seem to work either. I did do the modifications to get the hooks in, but its possible I did something wrong there.
I took another look at the modifications needed for the hook, and the bit I am unsure about is the first one. It says to find the section ‘Do we need pagination?’ and to insert the code snipper right before that line. I am not sure if that means right before ‘Do we need pagination?’ or right before ‘if ($this->paginate == TRUE)’?