Jump to content

rel tags


Lyleyboy

Recommended Posts

Hi all,

 

I have a prospective question. I have no code yet as this is just an idea.

 

Does anyone know a way whereby I can access the data stored in an HTML rel tag for instance.

 

<a href='www.google.co.uk' rel='Link to google'>Google</a>

How could I extract the

Link to google

 

Thanks in advance.

 

 

Link to comment
https://forums.phpfreaks.com/topic/172303-rel-tags/
Share on other sites

Firstly I should explain that I'm not too good at this.

 

The point is to create a kind of cut down CMS. So the client uploads a page that has say a <p> tag with a rel='para1'

It doesnt have to be a rel by the way, a class could work too.

 

My code can then be like a back end. I can then pull all the details of that element i.e. the content of the <p> and put it into a form.

Then save it back out.

 

I hope that makes sense...

Link to comment
https://forums.phpfreaks.com/topic/172303-rel-tags/#findComment-908514
Share on other sites

you will learn soon that parsing HTML is not an easy task. if everything was perfectly coded, you could use XML libraries to do exactly what you want...but as soon as someone forgets to close a tag or has something out of order at all...the entire block of HTML is unreadable.

 

for that reason, most people end up parsing it with commands like preg_match(). this allows you to set a matching pattern to look for. finding a single item like a <a> tag is pretty straight forward...but it gets complicated when you have nested elements

Link to comment
https://forums.phpfreaks.com/topic/172303-rel-tags/#findComment-908532
Share on other sites

The idea is that the user can upload a html document which is effectivly a letter but in HTML format.

 

Then we can use some cool code (Which I clearly can't write yet!) to replace some details like the address and event name etc etc.

 

So really we're creating a template so it can be re used but there won't be a finite number of documents so I don't to sit there and code each template so it can be read by php.

 

 

Link to comment
https://forums.phpfreaks.com/topic/172303-rel-tags/#findComment-908540
Share on other sites

No the rel was just my thought of the best way to do it.

 

I could just go with %ADDRESS%

 

So what I'd like to now do is to

1, Say, Which template do you want to use?

2, Open that template and replace the details. Some from the DB and some from a form like the letter's body.

 

I can set up a template picker without too much difficulty it's just then replacing the details from both the form and based on a mysql query.

 

Sorry if I was a bit vague at the beginning. This is just developing as we talk.

Link to comment
https://forums.phpfreaks.com/topic/172303-rel-tags/#findComment-908558
Share on other sites

well...if you are using placeholders like described above, you can just use str_replace() to find/replace the values. personally, i would use Smarty though...which is a PHP Templating engine...but it might be a little bit more then you want to get into.

 

for str_replace()...you first need to collect all your data and have that ready...then load up the template (either from a form or from something in your db)...then it's just str_replace() on the template code for each of the placeholders

 

Link to comment
https://forums.phpfreaks.com/topic/172303-rel-tags/#findComment-908562
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.