Форуми / Cotonti / Support / ParseBlock Help

medj
#1 23.02.2009 02:48
Hello, I was wondering if someone could help me out with what I'm trying to accomplish.

I have a function that will parse tags in HTML. I know users of Seditio and Cotonti are all familiar with this method.

First off, here is some code:

class Parser {
  function ParseTags($Template, $ParseTags) {
    $Template = file_get_contents($Template);
    foreach($ParseTags as $UnParsed => $Parsed){      
      $Template = str_replace("{".$UnParsed."}", $Parsed, $Template);
      }
    return $Template;
    }

This will basically look at one of my HMTL files and convert any tags into the data that should be displayed for that page. This works fine.

My question is basically if anyone knows how to implement a parseblock function. A very simple one in which on my HTML file I can have the following code:

{START: SHOW_NEWS}
{row_news_title}
{row_news_body}
{END: SHOW_NEWS}

And basically it would repeat this for as many news posts as I want to show on a page.

Even if someone has a link for me to learn how to do this, that would be fine. I was searching for "ParseBlock" and didn't come up with any help.

Thanks.
Trustmaster
#2 23.02.2009 02:57
Are you reinventing XTemplate?
May the Source be with you!
medj
#3 23.02.2009 03:29
Um, to be honest, I don't know what XTemplate is but I'm gonna look into it.


EDIT:
I just took a quick look at XTemplate.
All I have to do is include the xtemplate.class file. From what I understand, this should give me all the functionality that I was looking for.
Thanks for this idea, I will look more into XTemplate later on when I get back home.

Відредаговано: medj (23.02.2009 03:44, 16 років тому)
Trustmaster
#4 23.02.2009 04:31
You don't need to include anything, mate! XTemplate is what Seditio/Cotonti uses to render TPL files. So you just use it this way:
$my_tpl = new XTemplate('path/to/file.tpl');
$my_tpl->assign(array(
'TEST_1' => $some_var,
'TEST_2' => $another
));

$my_tpl->parse('MAIN.MY_BLOCK');

$my_tpl->parse('MAIN'); // Parse main block
$output = $my_tpl->text('MAIN'); // return contents
$my_tpl->out(); // output contents
May the Source be with you!
Kilandor
#5 23.02.2009 06:22
You can create a new Xtemplate with any file, it could be called .txt, .html it doesnt' matter.

So jsut create a PHP file, and run your html file through xtemplate.
medj
#6 23.02.2009 14:45
Thanks a lot for the help guys.

Is it just me or does the "copy to clipboard" function not work?
Orkan
#7 23.02.2009 22:32
# medj : Is it just me or does the "copy to clipboard" function not work?

Is working for me, using FF2... what is your specs?
Perl - the only language that looks the same before and after RSA encryption.
Trustmaster
#8 23.02.2009 22:59
Neither it it works for me: Ubuntu 8.10, FireFox 3.0.6.
May the Source be with you!
medj
#9 24.02.2009 00:19
I have Windows XP, Firefox 3.0.6. as well.
Kilandor
#10 24.02.2009 07:40
Same, doesn't work for me, but XP, FF 3.0.6
kripteks
#11 24.02.2009 08:24
Verifi script blocking
kripteks();