ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

PHP In templates

October 05, 2011 10:26am

Subscribe [2]
  • #1 / Oct 05, 2011 10:26am

    Shaun_Warren

    3 posts

    Hello EE i have a bit of a problem here and wondering if you could help me understand.
    To give you a better understanding i will explain what i am trying to do first.

    Explanation:
    I am trying to use PHP inside a template.

    I have a template which retrieves a user’s information for their profile page. What i am trying to do is get all this information and check if its filled out correctly. For instance say there is 5 sections of the profile, 3 of them are filled out but the other 2 are not, it will display at the bottom that only 60% is filled in.

    Now what i am having problems with is getting EE tags into a PHP variable and checking them with if statements.

    Say a Matrix field, it simple returns as 1. Not as an array, is this meant to happen?

    ——————————
    I have a matrix field called education (holds educational data about the person)
    It has 6 columns:
    Graduation year, Uni name, Country, Qualifications, Degree Table and Result.

    Now when using this piece of code

    <?PHP echo '{education}'; ?>

    It returns a value of ‘test uni maths’ which is only the Uni name and Qualifications

    Now if i use the code

    <?PHP print_r('{education}'); ?>

    it returns a value of ‘test uni maths 1’. I don’t even know where the 1 is coming from.

    I had the thought of using {field:education} which just displays the matrix entry field.

    Is there a process i am missing about using EE tags inside of php (remember using it inside of templates)?

    Is it even possible to accomplish what i am trying to do without creating a plugin or module?

    ——————————-

    Another problem i am finding is in the profile we have multiple-select drop-down lists which are populated by categories, how would i go about getting the category list of that user into an array?

    Moved to Community Help forum by Moderator

  • #2 / Oct 06, 2011 8:17am

    Sue Crocker

    26054 posts

    Hi, Shaun_Warren.

    When it comes to working with Matrix, I’m going to need to move this to the Community Help forum for additional community support.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases