General content block not working in news article [solved]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
babel
Forum Members
Forum Members
Posts: 149
Joined: Fri Oct 19, 2012 8:58 pm

General content block not working in news article [solved]

Post by babel »

I've a global content block which my client would like to placed after every article. It's a mailchimp-form. Unfortunately it only shows

Code: Select all

{global_content name='nieuwsbrief'}
. Is it possible to use global content block in news-article? If yes, how?
This is the systeminformation:

Code: Select all

Cms Version: [b]1.12[/b]

Installed Modules:

    CMSMailer: [b]5.2.2[/b]
    CMSPrinting: [b]1.0.5[/b]
    FileManager: [b]1.4.5[/b]
    MenuManager: [b]1.8.6[/b]
    MicroTiny: [b]1.2.9[/b]
    ModuleManager: [b]1.5.8[/b]
    News: [b]2.15.1[/b]
    Search: [b]1.7.12[/b]
    ThemeManager: [b]1.1.8[/b]
    FormBuilder: [b]0.8.1.1[/b]
    Captcha: [b]0.5.2[/b]
    TinyMCE: [b]2.9.12[/b]
    CGSimpleSmarty: [b]1.9.1[/b]
    CGExtensions: [b]1.49.12[/b]
    FrontEndUsers: [b]1.30.6[/b]
    CustomContent: [b]1.10[/b]
    SelfRegistration: [b]1.9.3[/b]


Config Information:

    php_memory_limit: [b][/b]
    process_whole_template: [b][/b]
    max_upload_size: [b]60000000[/b]
    url_rewriting: [b]mod_rewrite[/b]
    page_extension: [b][/b]
    query_var: [b]page[/b]
    image_manipulation_prog: [b]GD[/b]
    auto_alias_content: [b]true[/b]
    locale: [b][/b]
    default_encoding: [b]utf-8[/b]
    admin_encoding: [b]utf-8[/b]
    set_names: [b]true[/b]


Php Information:

    phpversion: [b]5.4.41[/b]
    md5_function: [b]Aan[/b] (Waar)
    gd_version: [b]2[/b]
    tempnam_function: [b]Aan[/b] (Waar)
    magic_quotes_runtime: [b]Uit[/b] (Onwaar)
    E_STRICT: [b]2048[/b]
    E_DEPRECATED: [b]0[/b]
    memory_limit: [b]128M[/b]
    max_execution_time: [b]3000[/b]
    output_buffering: [b]4096[/b]
    safe_mode: [b]Uit[/b] (Onwaar)
    file_uploads: [b]Aan[/b] (Waar)
    post_max_size: [b]60M[/b]
    upload_max_filesize: [b]60M[/b]
    session_save_path: [b]Geen controle omdat 'open_basedir' actief is[/b]
    session_use_cookies: [b]Aan[/b] (Waar)
    xml_function: [b]Aan[/b] (Waar)
    xmlreader_class: [b]Aan[/b] (Waar)


Server Information:

    Server Api: [b]cgi-fcgi[/b]
    Server Db Type: [b]MySQL (mysqli)[/b]
    Server Db Version: [b]5.5.27[/b]
    Server Db Grants: [b]Er is een "GRAND ALL" permissie gevonden, alles lijkt in orde.[/b]
    Server Time Diff: [b]Geen tijdverschil aangetroffen[/b]
Last edited by babel on Sat Nov 14, 2015 3:38 pm, edited 1 time in total.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: General content block not working in news article

Post by Rolf »

Use eval to call the news content block in your template
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
babel
Forum Members
Forum Members
Posts: 149
Joined: Fri Oct 19, 2012 8:58 pm

Re: General content block not working in news article

Post by babel »

Rolf, I don't understand your answer. What is eval?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: General content block not working in news article

Post by Jo Morg »

"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
babel
Forum Members
Forum Members
Posts: 149
Joined: Fri Oct 19, 2012 8:58 pm

Re: General content block not working in news article

Post by babel »

Sorry, I dont know much about smarty or php. I find it strange that with news articles you can not use a global content block the usual way like

Code: Select all

{global_content name='nieuwsbrief'}
but need some special code. Anyway, with eval I'm not able to use the global content. Is there another solution?
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: General content block not working in news article

Post by Jo Morg »

babel wrote:I've a global content block which my client would like to placed after every article. It's a mailchimp-form.
Well, to be honest you are not providing much information on how you are using the GCB on the news template. We assumed that you were inserting the GCB tag on some field on the News submission form. But the best way is to put the tag directly on the News template... if it is not being parsed, then you must be doing something wrong, but you need to explain all the steps you are taking and where it is failing...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
babel
Forum Members
Forum Members
Posts: 149
Joined: Fri Oct 19, 2012 8:58 pm

Re: General content block not working in news article

Post by babel »

The steps I take.
1. Making a global content block with the mailchimp-code in it
2. Copy the tag in the content block of an article so the mailchimp-form would show at the end of an article. Turn the wysiwyg off.
3. After submitting I see the tag

Code: Select all

{global_content name ="nieuwsbrief"}
but not the form.
It works when I put the global contant tag in a template, but not in a newsarticle.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: General content block not working in news article

Post by Jo Morg »

babel wrote:It works when I put the global contant tag in a template, but not in a newsarticle.
If you put it on the News article details template it works, of course, and if that GCB is going to be used, as you stated, on every news article that is the correct way to do it.
The eval solution along with step 2, although good for some situations is not optimal, as the field will then be evaluated creating some overhead. Additionally you are mixing content editing with presentation logic, which is not recommended.
However if you insist on using step 2, you'll have to assign the field to a smarty var and then eval that var:

Code: Select all

{* sample pseudo code *}
{$foo=$item.fieldname->value}{eval var=$foo}
That is pseudo code as I don't have the field calling tag present atm.
Additionally, this type of situation has been answered frequently on the forum so if you do a search you'll find answers on how to use {eval} along with News or most other modules' templates.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
babel
Forum Members
Forum Members
Posts: 149
Joined: Fri Oct 19, 2012 8:58 pm

Re: General content block not working in news article

Post by babel »

Jo, thanks for your answer. I put the code in the wrong template. The details template is the correct answer. So no need for the use of eval.

Thanks again.
Locked

Return to “Modules/Add-Ons”