Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Element Instantiation Question (am I misunderstanding XHP?) #9

Closed
Chado opened this issue Feb 24, 2010 · 4 comments
Closed

Element Instantiation Question (am I misunderstanding XHP?) #9

Chado opened this issue Feb 24, 2010 · 4 comments

Comments

@Chado
Copy link

Chado commented Feb 24, 2010

Slightly confused about the syntax for element instantiation.. am I misunderstanding XHP?

Would love to start writing new namespace elements to use as front-end components for quick reuse...

...is this an appropriate use of XHP?

Actual attempt, seems if I echo the element it works, if I embed the element in a broader chunk of html it fails...

ie: http://pastebin.com/JWGseQfN

... do we have any basic examples of the proper way to define and instantiate elements in the broader scope of a front end template? Any source examples of the "right way" to use XHP would be very helpful.

... also, is there a discussion forum anywhere for XHP? Do not want to pollute the github ticketing system.

Thanks everyone,

Chado

@Chado
Copy link
Author

Chado commented Feb 24, 2010

Looks like github obfuscated my code...

i've added the desired outcome to this updated pastebin:

http://pastebin.com/XRqpw9CV

@Chado
Copy link
Author

Chado commented Feb 25, 2010

Basically, in a sense.. i'm looking to use XHP to help with building FBML mashups... but also, I notice a problem as XHP tries to render the FBML sytanx:

ie: if I render() the following from within an element class:

<fb:friend-selector uid="$uid" name="uid" idname="referrer" prefill_id=""/>

It will try to use XHP to render <fb:friend-selector (expectedly).

Is there a way to get FBML/XHP to play nice?

I thought adding the following might work, but no luck:

protected $tagName = 'fb:friend-slector';

@Chado
Copy link
Author

Chado commented Feb 25, 2010

I guess I could theoretically add every fbml element to html.php? I'm hopeful there is another way...?

@laverdet
Copy link
Contributor

laverdet commented Mar 2, 2010

So with regards to the pasted code, you should try doing echo $el->__toString() so that you can see what the exception is. Zend has a design flaw where exceptions thrown from a string cast result in a fatal instead of unwinding the stack like they should. If you manually call __toString() you can see what the exception is and correct it.

With regards to FBML you will have to define them all yourself. Check out php-lib/html.php -- we define each and every HTML element you can use, including attributes and children. XHP has no idea what you want to render until you tell it what to do.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants