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

Custom Fields in {exp:weblog:entries /}

Development and Programming

mhulse's avatar
mhulse
329 posts
18 years ago
mhulse's avatar mhulse

This worked for me… Many thanks Mark! I was able to display four different articles on the homepage based on custom field dropdown menu. Very cool. IMVHO, this type of functionality should be built into EE.

Woot! Thanks again.

Cheers, Micky

       
Linda A's avatar
Linda A
647 posts
18 years ago
Linda A's avatar Linda A

I am getting the following error on a template where I use the custom fields extension, and I am wondering if it may be what’s causing the error:

MySQL ERROR:

Error Number: 1064

Description: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE t.entry_id !='' AND t.entry_date < 1177334641 AND (t.expiration_date = 0' at line 2

Query: SELECT t.entry_id FROM exp_weblog_titles AS t LEFT JOIN exp_weblogs ON t.weblog_id = exp_weblogs.weblog_id LEFT JOIN exp_weblog_data AS wd ON t.entry_id = wd.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id INNER JOIN exp_weblog_data AS d ON t.entry_id=d.entry_id AND WHERE t.entry_id !='' AND t.entry_date < 1177334641 AND (t.expiration_date = 0 || t.expiration_date > 1177334641) AND exp_weblogs.is_user_blog = 'n' AND t.weblog_id = '32' AND t.status = 'open' ORDER BY t.sticky desc, wd.field_id_144 asc LIMIT 0, 1
       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Can you write out the weblog:entries tags you’re using so I can try to figure out what’s causing the problem? thanks.

       
Linda A's avatar
Linda A
647 posts
18 years ago
Linda A's avatar Linda A
{exp:weblog:entries weblog="{current_weblog}" limit="1" orderby="{current_weblog_id}_number_sorting" sort="asc" dynamic="off" 32_number_display="{segment_3}"}{weblog} - {{current_weblog_id}_number_display} {title}{/exp:weblog:entries}

‘32_number_display’ is the custom field. This template is setup to be accessed with segments added, and the error occurs only when no segment at all is added, so it probably relates to that. But I am not sure how to work around that.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

hum…you’d probably just want to drop a conditional in there:

{if segment_3}
{exp:weblog:entries}
{if:else}
Sorry, you didn't search for anything?
{/if}
       
Linda A's avatar
Linda A
647 posts
18 years ago
Linda A's avatar Linda A

Oh, okay. That seems to work, though the error did come and go oddly yesterday (must have been some caching issue involved).

Thanks. 😊

       
sam5's avatar
sam5
9 posts
about 18 years ago
sam5's avatar sam5

Hi there, The extension sounds great but I don’t have the code you mention in the top of the actual extension file in my mod.weblog.php

The second bit should be this according to the note in the extension file:

$sql = "SELECT * FROM exp_relationships 
    WHERE rel_child_id IN ('".implode("','",      
        array_keys($this->reverse_related_entries))."')
    AND rel_type = 'blog'";

Closest to that is this:

$sql = "SELECT * FROM exp_relationships WHERE rel_id IN (";
        
        $templates = array();
        foreach ($this->related_entries as $val)
        { 
            $x = explode('_', $val);
            $sql .= "'".$x['0']."',";
            $templates[] = array($x['0'], $x['1'], $TMPL->related_data[$x['1']]);
        }
                
        $sql = substr($sql, 0, -1).')';
        $query = $DB->query($sql);

it goes on….

Why is this? Does this extension work in all versions of Expression Engine above 1.4?

       
Mark Huot's avatar
Mark Huot
587 posts
about 18 years ago
Mark Huot's avatar Mark Huot

What version of EE are you running?

       
sam5's avatar
sam5
9 posts
about 18 years ago
sam5's avatar sam5

1.4.1

       
jeremydouglas's avatar
jeremydouglas
292 posts
about 18 years ago
jeremydouglas's avatar jeremydouglas

Just wondering if anyone has thoughts on how to get this to work with a custom date field searching for an entry corresponding to the current time.

Something like…

{exp:weblog:entries weblog="theWeblog" custom_Time_Field=">{current_time}” }

       
jeremydouglas's avatar
jeremydouglas
292 posts
about 18 years ago
jeremydouglas's avatar jeremydouglas

I thought even using php when the template is set to parse on input would work. Should this work or is there a reason why it won’t?

something like:

custom_field=”mktime(0, 0, 01, 01, 01, 2007);”

Thanks if there’s any help for this.

       
jeremydouglas's avatar
jeremydouglas
292 posts
about 18 years ago
jeremydouglas's avatar jeremydouglas

Actually I think it’s working for me now. Answered my own question 😊

       
Linda A's avatar
Linda A
647 posts
17 years ago
Linda A's avatar Linda A

I am looking at how to implement the hooks for the extension in 1.6, and it looks like that section of mod.weblog.php has changed, so I am not quite sure where to insert the extra code anymore.

Perhaps the extension won’t even work with 1.6? Has anyone tested it yet?

       
Mark Huot's avatar
Mark Huot
587 posts
17 years ago
Mark Huot's avatar Mark Huot

Thanks for the heads up Linda, I’ll check this out today and see what’s changed.

       
UltraBob's avatar
UltraBob
186 posts
17 years ago
UltraBob's avatar UltraBob

Thanks for reminding me, I had put the hooks back in but not tested it. It is working fine for me. Mark would it be helpful if I posted a new set of intructions about where to insert things when I get back to work on Monday? It looked like they changed the query for reverse related entries, so there may be some optimization to be done, but for what I’m using it for anyway it still works beautifully.

       
First 6 7 8 9 10 Last

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.