Constructing complext CSS commands using PHP

  • Unknown's avatar

    Hi, I’m trying to achieve the following but no success yet. Could you please help me achieve this?

    In wordpress post, I would like to a complex div expression. I’m currently be able to do this by typing the actual expression, everything seems to be showing up correctly. For example, I have 3 div classes (Top-Level, Left, Right). One class specifies the font, border and color attributes and the other 2 divs help me to align the text to the left and to the right respectively. So in my post, I would have to type the following commands, it is very tedious to add and update:

    Here is what I’m currently doing:

    Some text..
    <div class=”Top-Level”><span class=”Left”>Some left align text1</span><span class=”Right”>Some right text1</span></div>
    <div class=”Top-Level”><span class=”Left”>Some left align text2</span><span class=”Right”>Some right text2</span></div>
    <div class=”Top-Level”><span class=”Left”>Some left align text3</span><span class=”Right”>Some right text3</span></div>
    <div class=”Top-Level”><span class=”Left”>Some left align text4</span><span class=”Right”>Some right text4</span></div>

    This method works great. But as you can see if I want to change, it is very difficult to maintain. What I’m thinking is that if I write a PHP function that takes 2 arguments (1st argument = the left text, 2nd argument = the right text), then it would automatically give me the div expression the way I needed like the following:

    Some text…
    <?php great_function(‘Some left text1’, ‘Some right text1’); ?>
    <?php great_function(‘Some left text1’, ‘Some right text2’); ?>
    <?php great_function(‘Some left text3’, ‘Some right text3’); ?>
    <?php great_function(‘Some left text4’, ‘Some right text4’); ?>

    The above code is very easy to maintain but how would I write the above function and hook this up like above in my post?

    How do I write this great_function() in PHP or do you have some other better method to substitute the complex expression with a macro substitution like in C/C++ language (#define) ? Where do I put it? And how do I call it in the post?

    Could someone help me to achieve this?

    Thank you very much, JK

  • Unknown's avatar

    You need to ask here: http://wordpress.org/support We don’t have access to php files here at wp.com.

  • The topic ‘Constructing complext CSS commands using PHP’ is closed to new replies.