AdvancedContent

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked

What do you think: Use the image uploads dir or just the uploads dir for {content_image}?

image uploads dir
23
68%
uploads dir
8
24%
don't care
3
9%
 
Total votes: 34

NaN

Re: improve the content type "content"

Post by NaN »

You were a few minutes too fast ;)
Just download it again.
I just applied a patch to it some minutes ago.
It should really work now.
NaN

Re: improve the content type "content"

Post by NaN »

JeremyBASS wrote:
{content type=image block='image1' dir='images/:::title:::' class='image' label='Image 1'}
Just in case someone wonders why this isn't working anymore: I changed the way of smarty processing in the latest release what is not yet included in the documentation.
The param "smartyOn" is renamed into "smarty".

And i forgot to replace the ::: with smarty delimiters '{' and '}'. So actually no smarty will be processed.
This has been fixed in SVN.

So if you want the result of a plugin, an udt or even a module to be used as value in backend you need to call your content block like this:

{content type='image' block='image1' dir='images/:::title:::' smarty=true class='image' label='Image 1'}

But as mentioned before this example will not work if the page is just created since there is no title at this time.
JeremyBASS

Re: improve the content type "content"

Post by JeremyBASS »

NaN wrote:
JeremyBASS wrote:
{content type=image block='image1' dir='images/:::title:::' class='image' label='Image 1'}
Just in case someone wonders why this isn't working anymore: I changed the way of smarty processing in the latest release what is not yet included in the documentation.
The param "smartyOn" is renamed into "smarty".

And i forgot to replace the ::: with smarty delimiters '{' and '}'. So actually no smarty will be processed.
This has been fixed in SVN.

So if you want the result of a plugin, an udt or even a module to be used as value in backend you need to call your content block like this:

{content type='image' block='image1' dir='images/:::title:::' smarty=true class='image' label='Image 1'}

But as mentioned before this example will not work if the page is just created since there is no title at this time.
wait you mean you found a way to take

{content type='image' block='image1' dir='images/:::title:::' smarty=true class='image' label='Image 1'}


to


{content type='image' block='image1' dir='images/{title}' smarty=true class='image' label='Image 1'}

???

Guess I need to look back but I swear there was a major reason why that didn't work 100%, even with setting and reseting the smarty delimiters on the fly...  I'm interested to see :D
NaN

Re: improve the content type "content" - Content (Extended)

Post by NaN »

Yes and No ;D

dir='images/{title}' will work since it is wrapped in quotes. So in frontend it will be handled like text and not as smarty and therefore it won't cause trouble.

But the problem is the search pattern in backend when the template is parsed for {content ...} and its params.
At this time the pattern is '/{content2?(\s([^}]*))*}/'
What means the script searches for "{content" optionally followed by "2" followed by any kind of string but "}" ... and this is the problem.
Since if you have a "}" as value of a param it will stop parsing the content params. So any further params or values will be ignored.
In brief it would only work if it is the last item in this string.
But it would exclude the closing "}". So if you would use

Code: Select all


{content type='image' block='image1' dir='images/{title}' smarty=true class='image' label='Image 1'}

The parsing result would be

Code: Select all

 

{content type='image' block='image1' dir='images/{title

and the found params and their values would be

Code: Select all


type => image
block => image1
dir => images/{title <- This would cause a smarty error when processing the value in backend because of the unclosed title tag.

So i inserted the preg_replace('/::: ([^:]+):::/','{$1}',$item) again.
But i changed the way smarty is processed.
Now there will no module api used anymore by just grabbing any module that can be found.
This implied that there had to be at least one module installed - anyway in one line you explicitly refered to the news module.
So i created an own smarty function that is similar to the smarty plugin {eval}.
But this may need some testing.

EDIT: Okay, i have to correct this: dir='images/{title}' won't even work in frontend. It only worked in my test environment where i wrapped the {content} stuf in my template in {* {content} *}

NOTCIE:
If you use :::title::: as parameter value this value will be processed by the {title} plugin.
When adding a page the page actually does not exist yet. That means the {title} plugin returns the text "404 Error" as title.
Also many other plugins needs information that is only available when the content is rendered by the frontend (as i know  at least 12 plugins of the default ones).
So using page related data as parameter value is not recommended.

I will see if those values can be triggered by an extra param to have a predefined default value.
Last edited by NaN on Sun Mar 28, 2010 9:18 pm, edited 1 time in total.
JeremyBASS

Re: improve the content type "content" - Content (Extended)

Post by JeremyBASS »

Yeah it sounds like you went down the same path I did.. I tried {{ }} which is what I use in my ScriptDeploy mod but anything with {} dies.  That was why I ended up with the

{content
block="test"
type="dropdown"
items=":::global_content name=test:::"
smartyOn="true"
}

But that is much better then instead of

{content
block="test"
type="dropdown"
items="color of money,sports,road and rides,oasis,travel,sun blog,seniors,style,politics,sun report,travel,stateside,week in review,health,diaspora,entertainment,inside philly,freedom quest,education,food and beverage,go with the flo"
}

Heck I've been using it to call blog cat lists, maps from CGGM and so much more .. it's great to be able to do some mod call like :::news::: ...  I even have been doing some sweet smarty logic like

items=":::if $foo=='bar'::: :::global_content name=test::: :::/if:::"

kind of nifty to have that dynamic of a page editing area :D


Also one last note on the :::title::: IIRC if you have the title filed before you switch to the extend content type and then the template that has it, it picks up the title.. but one, I bet, could do something like

items=":::capture assign=$title::: :::title::: :::/capture:::
:::if $title=='':::
:::global_content name=$title:::
:::elseif(isset($smarty.post.title)):::
:::$smarty.post.title:::
:::else:::
::: global_content name='fall-back':::
  :::/if:::"

I’d think :D .. the point would be that you can add logic to control the way the page is presented to the client when editing… I'm not sure if module_custom will take over this in 2.0
NaN

Re: improve the content type "content" - Content (Extended)

Post by NaN »

This one might also work with smarty processing:

{content
block="test"
type="dropdown"
items=$smarty.ldelim|cat:"global_content name='test'"|cat:$smarty.rdelim
smarty="true"}

So the preg_replace( ::: ) - stuff  is not needed and the value could be processed directly.
But it is not really nice to read.

Anyway i've heard that in future smarty releases nested smarty processing ( {foo var={bar}} ) will be integrated. That means things that only belong to the backend panel would also be processed in frontend if we would use the default smarty delimiter here.
So i think the ::: delimiter is good deal to define what will only processed in backend.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: improve the content type "content" - Content (Extended)

Post by applejack »

This is great guys, very exciting and really well done, I truly appreciate all your hard work on this. It opens up numerous possibilities which weren't there before. I use a lot of cgisimplesmarty calls to pull in data from multiple pages onto one page which I am pretty sure this will help a editor to be able choose which page data they want to use I just need to get my head around how to set this up as I haven't had time to use this yet.

One thing which would be nice for the dropdown and multi select options is to have different values from their labels which unless I am mistaken cannot be done as yet. If it can then please let me know.

Also a notes type block would be great in order for admin to add notes which possibly the editor cannot edit though in other ways it would be useful for an editor to be able to add their own notes. This wouldn't have to show in the front end but one could just use a regex_replace to remove all content from displaying. I may have just answered my own question there...
Last edited by applejack on Tue Mar 30, 2010 1:08 pm, edited 1 time in total.

Website Design & Production
http://www.applejack.co.uk
NaN

Re: improve the content type "content" - Content (Extended)

Post by NaN »

Yes you're right. At the moment values of dropdowns and multiple select lists are the same like the label of the items.
I could change this so that you have an additional param for the values. But this means, that the user needs to enter the item values in the same sequence and of same amount as the item labels.
I could fill the item values with the labels if there are less values entered as items and vise versa.
Hm.

What do you think?
Is this a good idea?
I mean, if you have something like this in your template:

Code: Select all


{content type="dropdown" items="Foo,Bar,Gloo" values="1,2" assign="var"}

will result in a dropdown with item values 1, 2 and Gloo and item labels Foo, Bar, Gloo.

And

Code: Select all


{content type="dropdown" items="Foo,Bar,Gloo" values="1,2,3,4" assign="var"}

will result in a dropdown with item values 1,2,3,4 and item labels Foo, Bar, Gloo and 4

I'm not sure if this makes sense.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: improve the content type "content" - Content (Extended)

Post by applejack »

Hi Nan

Yes that would be great to be able to have different values and labels as often a label which is more easily understood by an editor is far harder to process than say values of 1 2 3 4

Website Design & Production
http://www.applejack.co.uk
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: improve the content type "content" - Content (Extended)

Post by applejack »

Another question.

When using a multi selection box with e.g. items="Foo,Bar,Gloo" how can this be utilised as as far as I know you cannot have variable arrays in  smarty tags so is there a split i.e. a pipe automatically inserted which can then be passed to a UDT for additional processing. (It is a while since I needed to use multi select boxes but it could be potentially very useful in this situation).

Website Design & Production
http://www.applejack.co.uk
NaN

Re: improve the content type "content" - Content (Extended)

Post by NaN »

Multiple selected items will be stored as string separated by comma.
So

Code: Select all


{content type="dropdown" items="Foo,Bar,Gloo" values="1,2,3,4" assign="var"}
{$var}

Will result in frontend in

Code: Select all


1,2,3,4

But you can explode it with smarty into an array:

Code: Select all


{assign var="$var_array" value=","|explode:$var}
{$var_array[0]}<br />
{$var_array[1]}<br />
{$var_array[2]}<br />
{$var_array[3]}

This will result in

Code: Select all


1
2
3
4

Notice:
Next days i release it as a module "XContent".
This includes the plugin {XContent} instead of {content2}. (But {content} will also work)
There the items of dropdowns and multiple select lists will be separated by a pipe "|".
Last edited by NaN on Tue Mar 30, 2010 1:40 pm, edited 1 time in total.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: improve the content type "content" - Content (Extended)

Post by applejack »

That is interesting, I didn't know you could use explode that way as it is not mentioned on smarty.net Thanks for you help really appreciate it and if you make the addition to different values and items then great.

Website Design & Production
http://www.applejack.co.uk
User avatar
NikNak
Forum Members
Forum Members
Posts: 183
Joined: Fri Oct 02, 2009 2:28 pm

Re: improve the content type "content" - Content (Extended)

Post by NikNak »

Hi NaN

The older version of Content2 parsed this fine, but the new one ignores it.

{content block="location code" assign="location" type="dropdown" items=':::global_content name=location_codes:::' smarty=true default=''}

I have tried the {} and the ldelim and rdelim noted earlier, but I cannot seem to get the smarty to work any more.

I'm confused, can you help?

Thanks

nik
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: improve the content type "content" - Content (Extended)

Post by hexdj »

Nan: thanks for adding this awesome plugin in the forge!!!
NaN

Re: improve the content type "content" - Content (Extended)

Post by NaN »

NikNak wrote: Hi NaN

The older version of Content2 parsed this fine, but the new one ignores it.

[...]
Have you tried to wrap the values of the params in quotes?
As the ContentType will be replaced by the module XContent in future releases i did no further investigations in fixing the ContentType itself.
The module is almost ready to go.
So just be patient.
Locked

Return to “Modules/Add-Ons”