8 years ago
8
Topic

Hello all, stormy day here in northern Utah.

I'm till a Seblod beginner so please bear with my questions, I do try to find my answers on the forms or tutorials but sometime I strike out. I would be most appreciative on how to best accomplish this task.

I have a content type where I want to put the choice of 3 different default messages, or leave blank. I'm thinking this would be a Simple Select to choose default message, but I'm not sure where to store the HTML string (value)  of the field. I could put it into the select field text=value format but what if I wanted a bit more eleborate HTML, perhaps with a link or the text from a variable on the form. Or I guess I could make a new content type for the messages, but this seems like overkill.  I only have 4 possible choices.

What I would really like is a default sentence (value of the select) that would be:

"This is the default message for getValue('art_title')".

or 

"This is the other default message for getValue('art_title')".

or

"This is the last possible default message for getValue('art_title')".

or no message


So I guess my question is two part.

1) where could I store default html messages

2) how can I put a variable in the message so it will pull the article title into the text of the message.

Thanks so much

Get a VIP membership
1283 Posts
Bucklash
8 years ago
2
Level 1

Hi Lownotes

Sorry to impose on your post but can't resist throwing out an idea:

1

*** Messages ***

Each message can be stored in a 'free text' field. 4 messages? 4 free text fields.

2

*** Select List ***

Create a select simple field::ie Message 1= 1;

Message 2=2;

Message 3=3;

Message Empty=0

3

*** conditionals ***

Use conditionals to show or hide the appropriate message (free text field)

4

*** dynamic values ***

Showing the article title or other value in the free text field?

Hmmm, what about the #my_field_name# syntax ie

#art_title#

?

Jon

1283 Posts
Bucklash
8 years ago
1
Level 2

Hi again

If that works...

Are you storing the select list value or storing the message in the form?

If storing the select list value... then just have storage as "standard :: article :: my_select_field"

If storing the message... I would use "beforestore" field. In it place a conditional statement similar to this... $fieldy = $cck->getValue('my_select_field');

$messagey = '';

if (1 == $fieldy) {

$messagey = $cck->getValue('my_message_1');

} elseif ( etc...

then

$config['storages']['db_table_name']['message_db_column'] = $messagey;

a switch statement would be better?

Bucklash

8 years ago
0
Level 3

HI Bucklash,

First I want to say thanks for all the great help that you share here.  Send me a link to your beer fund and I'll contribute!

Second, I think I see where you're going with your first post and based on your second post I see I could add some clarification here.  

What I was hoping to accomplish was a way that I could come back and edit message 1 (or 2...) at a later date and that all articles that had message 1 would show the current version (most recently edited) of message 1.  So I guess the answer to your question is no, I don't want to store the message, just a reference to it.  That the point of this is to create a way to come back and easily modify all of the instances of a message option by just editing the source.

8 years ago
3
Level 1

So I think I've got this understood and working.  This video also really helped with understanding conditional fields.

https://vimeo.com/112916855

My only question though is that I'm trying to control the visibility of the free text field when the user is looking at the content item on the front end.  As far as I can tell the conditional fields are only effected in the form views.  there isn't a #5 box for conditional fields when looking at the CONTENT view.

1283 Posts
Bucklash
8 years ago
2
Level 2

Hi lownotes

Beer fund eh? I'm more in to peanut m&m's if you have any. 

Thanks for the words :)

I think you would need

a) variation override

or

b) search and list type display the content (rather than using the content view) and do a crafty query there

if 'a) variation override':

site/templates/my_seblod_template/varitions/my_variation_1/my_variation_1.php

or something like that, then have a db query using value from select list as a variable to get the desired data from db. and construct the layout of fields accordingly.

Selecting_data_using_JDatabase

Bucklash

8 years ago
1
Level 3

Ok, I'm trying to understand both of these approaches but I think they're over my head.  I'm surprised this task ends up being so complex.

What about reconsidering the idea of creating a new content type called "messages" and using a module position that shows a list type to show the message in the content.  I think I've seen a video tutorial on something similar.

m&m's with nuts eh?  They're my favorite too.

1283 Posts
Bucklash
8 years ago
0
Level 4

Hi

Sounds like a plan.

The message in the module should be able to pick up any values from the main content ie $cck->getValue('art_title');

The Search in your list type will need to reference the select list value to get the right message.

It could get tricky again as it is a different content type.

What search fields/plugins do you have ie search join etc

Bucklash

8 years ago
0
Level 1

I thought I'd circle round here and share the solution that I came up with which was almost exactly as I had envisioned and just as easy as I envisioned it should have been.  I also had a little help.

1) Created three custom html modules, each with a declared module position name [msg1,msg2,msg3]

2) Admin Form: Created three module fields, each with same position names

3) Admin Form:Radio or Select with options the same as the position names

4) Content: Use Restriction on the module fields based on choice of the Radio/Select options.

The result is that when the user chooses which message to show (Radio/Select) then the appropriate module position will be visible while the others are not.

Thanks again for your help and suggestions on this one.

Get a Book for SEBLOD