1 of 3
1
Extension: MD Simple Relation. Creates a “simple” relationship field, storing only the entry_id.
Posted: 08 July 2008 08:22 AM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006

I was having an impossible time getting reverse_related_entries to work with categories - all I needed to do was store a related entry’s entry_id in a field - so that’s all this does.

Simple Relation looks and works identically to a native Relationship field type, but it avoids the relationship table altogether, creating a very “simple” relationship by storing only the related entry_id. This way you can use EE’s built-in weblog:entries “search” parameter to filter entries - which might be easier than trying to mess with Reverse Related Entries and multiple embeds when trying to sort by category. It may have other uses, but that’s all I need it for. Might save you from having to use the Query module, too.

See this post for an example of exactly how I’m using Simple Relation.

You can download Simple Relation here.

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 08 July 2008 10:03 AM   [ Ignore ]   [ # 1 ]  
Grad Student
Avatar
Rank
Total Posts:  69
Joined  05-01-2007

Looks nice, I’ll try it soon. Thanks for sharing it !

 Signature 

Portfolio : http://www.evasion.cc
Weblog : http://www.evasion.cc/blog

Profile
 
 
Posted: 10 July 2008 12:42 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  8
Joined  04-23-2007

How diificult would it be to extend Simple Relation to deal with one-to-many relationships, where multiple related entries can be selected. I guess it would need to store an array of entry ids instead of a single number. This would keep all the benefits, whilst making it similar to this plugin.

Profile
 
 
Posted: 10 July 2008 12:49 PM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  69
Joined  05-01-2007

Grant B, what your talking about seems similar to this, no ?

 Signature 

Portfolio : http://www.evasion.cc
Weblog : http://www.evasion.cc/blog

Profile
 
 
Posted: 10 July 2008 03:57 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  8
Joined  04-23-2007

evasion, the idea I have is similar to both Mark Huot’s multi-relation and to the Playa plugin. I will need to test whether each of them works with categories. It is great to see different plugins available that enable very flexible approaches to dealing with multiple-approaches.

Profile
 
 
Posted: 10 July 2008 04:15 PM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006
Grant B - 10 July 2008 12:42 PM

How diificult would it be to extend Simple Relation to deal with one-to-many relationships, where multiple related entries can be selected.

For me it would be difficult because:

1) I’m not super adept with PHP, so I’d have to figure out how to store the data
2) I’d have to (want to…) figure out a way to designate, per field, whether you wanted to store multiple id’s or a single id for that field (I do have an idea about how to do that, actually)
3) I’m a perfectionist - so I’d love to make it so you can drag and drop multiple selections to reorder them.
4) I’m so sleep-deprived this week that all of the above makes me want to weep. I want to go outside.

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 10 July 2008 04:34 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  8
Joined  04-23-2007
mdesign - 10 July 2008 04:15 PM

4) I’m so sleep-deprived this week that all of the above makes me want to weep. I want to go outside.

I’m going to take a look at the other possibilities to see how well they work with categories and then give some thought to the design to see how necessary categories are – so hopefully won’t be making any requests that will cause further weeping.

I’m looking forward to using your plug in for simpler relationships though. That is definitely going to let me get some things done on one of my existing sites.

Profile
 
 
Posted: 12 July 2008 10:40 AM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006

I do think I got this to work with Galleries, too. Check out this post, and the two screenshots there.

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 28 August 2008 10:50 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  173
Joined  08-25-2008

I’ve imported several thousand weblog entries into my EE install, and took the time to make sure that all of the relationships were set up right. Now that I’ve got the data imported, I’m trying to do stuff with it: and I find myself somewhat stymied by EE’s inability to search: by a relationship field.

I’ve been playing around with Simple Select, and I think it will do just what I need. My question, though, is: How can I convert all of my old relationships in to Simple Select relationships? Changing the field_type in exp_weblog_fields to simplerel from rel just erases my data.

Is this possible w/o reimporting everything? Or will I have to establish new “simplerel” relationships?

 Signature 

lukemcreynolds.com | some useful ee code snippets and tricks

Profile
 
 
Posted: 28 August 2008 11:05 AM   [ Ignore ]   [ # 9 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006

I’m not too familiar with the Relationships table - and this little extension was designed to stay away from it. When you say “Simple Select” do you mean “Simple Relation”?

I would imagine it wouldn’t be too difficult to write a query that copies part of the relationship data (just the ID needed) into the field for the Simple relationship - all the simple relationship is is a number, nothing else.

In order to maybe save you some work - what are you finding that the “real” relationship field isn’t doing for you? How are you trying to search?

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 28 August 2008 11:53 AM   [ Ignore ]   [ # 10 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  173
Joined  08-25-2008

Well, I’m making a bus schedule site. I’ve got three weblogs that hold the timetable data: one for routes, one for stops, and one for stop times. The stop times weblog has the time the bus stops at a particular stop (related to the stops weblog) and on a particular route (related to the routes weblog).

What I’m trying to do at the moment is display and format all of my data. This:

{exp:weblog:entries weblog="times" sort="asc" disable="trackbacks" search:direction="=S" search:day="=Weekday"}

{if count
== "1"}
{related_entries id
="stopname_times"}
<table border="1">
<
tr>
<
th>Stop: {title}Direction: {direction}<br>Day: {day}</th>
<
th>entry_id</th>
</
tr>
{/if}

{
/related_entries}
<tr>
<
td>{stoptime}</td>
<
td>{entry_id}</td>
</
tr>

{if count == total_results}
</table>
{/if}

{
/exp:weblog:entries}

is how I’m starting out: it lists all of the time-stops headed South on a weekday. (Direction and days that a route runs aren’t relationships - they’re just text.) However, there are hundreds of them: I need to narrow it down even further, and add the route and stop to the exp:weblog:entries tag, like

search:direction="=S" search:day="=Weekday"

.

Basically, I’m looking for the entry_id for each of the parent related entries. I’m still playing around with a custom SQL query similar to the one james brown used here: http://expressionengine.com/forums/viewthread/75163/#424802. We’ll see if that works.

Thanks for your help. grin

 Signature 

lukemcreynolds.com | some useful ee code snippets and tricks

Profile
 
 
Posted: 28 August 2008 12:02 PM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  173
Joined  08-25-2008

I’m thinking now that I could implement the route and stop information as categories associated with each weblog entry. Those are much more user-friendly.

 Signature 

lukemcreynolds.com | some useful ee code snippets and tricks

Profile
 
 
Posted: 21 September 2008 10:50 PM   [ Ignore ]   [ # 12 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006

I’ve updated Simple Relation, which you can download here.

The new version tweaks a few things:

- Update checking has been disabled in 1.1.2. The only setting now is whether to activate the extension on a site by site basis. Update checking may be back, but will incorporate LG Addon Updater if so.
- Officially changed the name to MD Simple Relation.
- Added Multi-Site awareness.
- Added ability to “simply relate” to either weblogs or galleries.

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 25 September 2008 01:51 AM   [ Ignore ]   [ # 13 ]  
Grad Student
Avatar
Rank
Total Posts:  88
Joined  05-21-2007

Thanks Ryan, this extension is just what I need to properly integrate galleries with my weblog publish form..

The only problem I’m having is a clash with the LG htaccess generator extension which is causing php notices to be thrown in the control panel:

Notice: Use of undefined constant MD_SR_version - assumed 'MD_SR_version' in .../core/core.extensions.php on line 229

Notice
: Use of undefined constant MD_SR_docs_url - assumed 'MD_SR_docs_url' in .../core/core.extensions.php on line 229

Notice
: Use of undefined constant MD_SR_addon_id - assumed 'MD_SR_addon_id' in .../extensions/ext.md_simple_relation.php on line 73

Notice
: Use of undefined constant MD_SR_extension_class - assumed 'MD_SR_extension_class' in .../extensions/ext.md_simple_relation.php on line 76

Notice
: Use of undefined constant MD_SR_addon_id - assumed 'MD_SR_addon_id' in .../extensions/ext.md_simple_relation.php on line 89

I noticed there are a few .htaccess lines commented out in the ext.md_simple_relation.php file itself, around line 181

/*     if(empty($site_settings['htaccess_path']) !== TRUE && substr($site_settings['htaccess_path'], -1) != "/")
        {
            $site_settings['htaccess_path'] .= "/";
        } */

and again at line 203

//    $_SESSION['mdesign'][MD_SR_addon_id]['response'] = $this->generate_htaccess();

although not being much of an extension developer or php person I haven’t played with this code at all..

Please help!

 Signature 

Twitter | African Budget Safaris | New Release


EE 1.6.7 | PHP 5

Profile
 
 
Posted: 25 September 2008 02:01 AM   [ Ignore ]   [ # 14 ]  
Grad Student
Avatar
Rank
Total Posts:  88
Joined  05-21-2007

update:

When I quote the variables to remove the notices I get a session error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at .../engine/extensions/ext.md_simple_relation.php:1) in .../engine/extensions/ext.lg_htaccess_generator_ext.php on line 672
 Signature 

Twitter | African Budget Safaris | New Release


EE 1.6.7 | PHP 5

Profile
 
 
Posted: 25 September 2008 03:58 PM   [ Ignore ]   [ # 15 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006

Wow, yikes. Let me take a look and see what I might have royally screwed up!

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 25 September 2008 04:15 PM   [ Ignore ]   [ # 16 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006

OK, there was definitely a typo in there - which I fixed. Replace version 1.1.2 with 1.1.3, which you can get from the MD Simple Relation page.

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 30 September 2008 12:12 AM   [ Ignore ]   [ # 17 ]  
Grad Student
Avatar
Rank
Total Posts:  88
Joined  05-21-2007

Thanks Ryan, although I’m still getting the clash with LG Htaccess Generator.. maybe I need to look at a new index.php removal method.

 Signature 

Twitter | African Budget Safaris | New Release


EE 1.6.7 | PHP 5

Profile
 
 
Posted: 30 September 2008 08:02 AM   [ Ignore ]   [ # 18 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2124
Joined  03-26-2006

No, this thing works with .htaccess generator, because I’m using both on a site right now. I’ll bet you I uploaded the same file by mistake, but gave it a new version number.

I’ll update the download (again…whoops!), but if you want to do a quick fix, disable the extension, then look at line 25 of ext.md_simple_relation.php, which is probably reading:

if ( ! defined('LG_HG_version')){

And change it to:

if ( ! defined('MD_SR_version')){

then re-enable the extension. That should fix the issue.

The reason that issue exists is because I was using Leevi’s .htaccess Generator extension as a model when I was making updates to this extension, and that was a simple copy/paste error.

 Signature 

ryan masuga
—————
Masuga Design (EE Pro) | devot:ee
MD Markitup | All Add-Ons
@masuga | @masugadesign | @devot_ee

Profile
 
 
   
1 of 3
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120472 Total Logged-in Users: 59
Total Topics: 126549 Total Anonymous Users: 33
Total Replies: 665393 Total Guests: 298
Total Posts: 791942    
Members ( View Memberlist )